RewriteEngine on RewriteRule ^/(dir1|dir2|dir3)/(.*)$ /targetfile.php [R,L]
http://www.somesite.com/dir1 -> http://www.somesite.com/targetfile.php
http://www.somesite.com/dir2 -> http://www.somesite.com/targetfile.php
http://www.somesite.com/dir3 -> http://www.somesite.com/targetfile.php
From what I’ve seen online, this should work. Unfortunately, it wont. Any insight?
If you want to use this in a .htaccess file, remove the leading slash from the pattern. And to match only full path segments, you have to alter the expression a little bit.
So try this: