Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess mod_rewrite .tld to specific folder

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.

like image 231
Lukas Oppermann Avatar asked Dec 05 '25 13:12

Lukas Oppermann


1 Answers

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]
like image 123
anubhava Avatar answered Dec 07 '25 16:12

anubhava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!