Racoon Posted February 27, 2010 Share Posted February 27, 2010 I want to redirect users to an error page if they enter any URL not starting with '/en/' or '/fr/'. I cannot figure out how to express this as a RewriteCond / RewriteRule. To be clearer, some examples: http://mysite.com/en/foo/ ==> Cool, do nothing http://mysite.com/fr/foo/ ==> Cool, do nothing http://mysite.com/fr/ ==> Cool, do nothing http://mysite.com/foo/ ==> ERROR, redirect to /404/index.php http://mysite.com/blah/foo/ ==> ERROR, redirect to /404/index.php I'm sure it must be pretty simple but I could not find this specific scenario addressed. If you could post the complete RewriteCond / RewriteRule, that would be awesome, as I'm quite the newbie with this. Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/193537-how-do-i-express-this-with-a-rewriterule-andor-rewritecond/ Share on other sites More sharing options...
cags Posted February 27, 2010 Share Posted February 27, 2010 Something like this should work, it's probably not the best solution, but it should work. RewriteCond %{REQUEST_URL} !^/en/ [OR] RewriteCond %{REQUEST_URL} !^/fr/ RewriteRule ^.*$ /404/index.php Link to comment https://forums.phpfreaks.com/topic/193537-how-do-i-express-this-with-a-rewriterule-andor-rewritecond/#findComment-1018921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.