Ben Ben - 1 year ago 167
Apache Configuration Question

.htaccess directory wildcard redirect

Please can someone tell me why this isn't working?

I am trying to redirect all files within the directory "Kent". In this example the page to be redirected is "ramsgate" and change the folder structure.





Using a wildcard redirect, why doesn't this work?

RedirectMatch 301 /electrical-contractors/kent/(.*).php /electrical-contractors-$1/

Answer Source

Have this rule inside /electrical-contractors/kent/.htaccess:

RewriteEngine On

RewriteRule ^(.+)\.php$ /electrical-contractors-$1/ [L,NC,R=301]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download