mod_alias subdirectory replacement

216 Views Asked by At

I am using RewriteMatch to redirect all traffic from subdir1 to subdir2, while keeping all other parts of the url the same. So for instance,

http://www.mydomain.com/subdir1/

would redirect to

http://www.mydomain.com/subdir2/

I am using this rule:

RedirectMatch 302 /subdir1/.* /subdir2/$1

which works for the url

http://www.mydomain.com/subdir1/

but not for any pages with longer urls. So it is not matching

http://www.mydomain.com/subdir1/index.htm

which should be redirected to

http://www.mydomain.com/subdir2/index.htm

If anyone has any ideas, I'd appreciate it.

2

There are 2 best solutions below

0
On BEST ANSWER

Does this thread help at all? http://www.webmasterworld.com/forum92/4097.htm

0
On

You would need to round brackets around your .*

RedirectMatch 302 /subdir1/(.*) /subdir2/$1

Without that $1 is meaningless and is not going to 'know' what to match on.