I am looking for a solution where i can define the muliple match statement whitin the single RewriteCond statement,
The scenario is i want to redirect to home page if any of this string comes in the url:
/it/, /de/, /fr/
I tried to wrote it like this:
This is throwing SERVER ERROR:
RewriteCond ^(/it/ | /de/ | /fr/ )
RewriteRule 'myhomepageurl'
I also tried this way too:
RewriteCond /it/ [OR]
RewriteCond /de/ [OR]
RewriteCond /fr/ [OR]
RewriteRule 'myhomepageurl'
This was giving unexpected results page loding infinite and admin was blocked. So i finaly took this way:
RewriteCond /it/
RewriteRule 'myhomepageurl'
RewriteCond /de/
RewriteRule 'myhomepageurl'
RewriteCond /fr/
RewriteRule 'myhomepageurl'
I am just curious about the single statement that can do this in single shot.
Thanks
Your first example is failing because of the spaces; a better regex would be something like
RewriteCond ^/(it|de|fr)/
RewriteRule 'myhomepageurl'
Either way, you should read When Not To Use Rewrite and use one of the simpler forms suggested there, e.g.
RedirectMatch /(it|de|fr)/ /myhomepageurl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With