Monday, 15 August 2011

apache - 301 redirect with complex directory regex -



apache - 301 redirect with complex directory regex -

i using @anubhava's solution folder redirect works great. 301 redirect 1 directory another

i realised need have 301 redirect next

redirect

1) www.example.com/directory1/dira/ 2) www.example.com/directory1/dirb/

redirect

1) www.example.com/directory2/new-path-dira/ 2) www.example.com/directory2/new-path-dirb/

edit: have lot of these redirects (about 40) , wondering if there way have 1 rewrite rule - instead of separate rules?

thanks!

you can add together these new rules:

rewriterule ^directory1/([^/]+)/(.*)$ /directory2/new-path-$1/$2 [nc,l,ne,r=301]

regex apache .htaccess redirect

No comments:

Post a Comment