Home > Software design >  Redirect every trailing folder to main folder
Redirect every trailing folder to main folder

Time:04-28

i have a couple of unwanted urls that i want to redirect:

/faq/
/faq/question/1-title
/faq/question/2-title

I want all the /faq/question/* urls to redirect to /faq, is that possible?

I have this but this doesnt work :

RedirectMatch 301 ^/faq/question/([^/] )/?$ /faq

CodePudding user response:

With your shown samples/attempts, please try following htaccess rules file. Make sure you are putting this new rule at top of your htaccess file(after https rules(to change http --> https rules) in case there are any present in your htaccess file).

Also make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
##Put your new rule here..
RewriteRule ^faq/question/ /faq? [R=301,L,NC]
###Make sure to keep rest of your urls here onwards...
  • Related