tags:

views:

29

answers:

2

How would I write a htaccess redirect rule if the URL contains a certain word

e.g. If contains "foobar" then redirect to index.php

Any help greatly appreciated

+2  A: 
RewriteCond %{REQUEST_URI} foobar
RewriteRule .* index.php

or some variant thereof.

Ignacio Vazquez-Abrams
Thanks for your quick response. Works perfectly but just realised instead of rewrite I need it to redirect. Is this possible?
Lee
Got it thanks - added [R]
Lee
+1  A: 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/foobar/i$ index.php [NE,L]
jordanstephens