Rewrite rules for subfolders

This may seem like a silly question, but I can't figure it out.

let's say I have a public_html folder with various folders, such as: Albatross, Blackbirds, Crows and Faqs.

I want to make sure that any traffic to Albatross / faqs.php, Blackbirds / faqs.php, Crows / faqs.php, etc. will see the file which is in faqs / faqs.php? bird = albatross or faqs / faqs.php? bird = crows or whatever you have.

If I go into the .htaccess file of the Albatross folder, I can do this

RewriteRule faqs.php$ /faqs/faqs.php?cat=albatross[QSA] 

Which works fine, but I want to put something in the top level .htacces, which works for all of them, so I tried:

 RewriteRule faqs.php$ /faqs/faqs.php?cat=albatross[QSA] RewriteRule /(.*)/faqs.php$ /faqs/faqs.php?cat=$1 [QSA] 

and even

 RewriteRule /albatross/faqs.php$ /faqs/faqs.php?cat=albatross [QSA] 

and others, but nothing works when I go to http://www.birdsandwhatnot.com/albatross/faqs.php I see the same file as always, Does the .htaccess file in the subfolder have a conflict with the file above .htaccess?

Did I miss something?

+4
source share
1 answer

A small correction should do the trick

 RewriteEngine on RewriteRule ^(.*)/faqs.php$ /faqs/faqs.php?cat=$1 [QSA] 

"/" is not passed to the parser.

Hope this helps

+2
source

Source: https://habr.com/ru/post/1306869/


All Articles