Reputation: 13
So I would like to know if it is possible to redirect multiple subdirectories to another domain using htaccess.
Current situation:
Ideally with redirects:
I read a little about Apache and its syntax, but I am still far from understanding it entirely. It seems to use regular expressions, but does not use '|' (or).
The website host instructs to write the htaccess as follows, where example.nl/webshop redirects to example.com/shop:
Redirect 301 /webshop http://www.example.com/shop
But I need it to redirect multiple, but not all, subdirectories. Is it possible using regular expressions and if so, how? If not possible to redirect multiple subdirectories, what are the alternatives?
Thanks in advance!
Upvotes: 1
Views: 552
Reputation: 41219
You can use mod-rewrite
to redirect your URLs . Try the following in your htaccess file :
RewriteEngine on
#redirect the specified lang paths to another domain
RewriteRule ^(nl|fr|en|it|es)/ https://example2.com%{REQUEST_URI} [NE,L,R=301]
Upvotes: 1