Question

I want to do the following, if possible, with htaccess.

The webpage works this way, you get the index file via domain.de/de/start and the english version via domain.de/en/start.

If a user visits domain.com I would like him to end up at domain.de/en/ instead of domain.de/de/ so I need to rewrite all requests to domain.com but NOT requests with domain.com/xx/something to domain.de/en/

Thanks.

Was it helpful?

Solution

If I understand you clearly you only want to redirect http://domain.com/ to http://domain.de/en/ but do NOT want to redirect http://domain.com/XX/YY

Put this code in your .htaccess:

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^$ http://domain.de/en/ [L,R=301]

OTHER TIPS

Try to use HTTP_HOST and rewritecond

RewriteCond %{HTTP_HOST}=domain.de
RewriteCond %{REQUEST_URI}=/              % redirect only the root
RewriteRule ^/$ /de/start [L]             % to /de/start

RewriteCond %{HTTP_HOST}=domain.de
RewriteCond !%{REQUEST_URI}=/             % no root
RewriteCond !%{REQUEST_URI}=/[a-z]{2}/.*  % except /xx/ directories
RewriteRule ^/.*$ /de/$1 [L]              % push the user in the /de/ directory
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top