pg.
pg.

Reputation: 2531

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 like: Albatross, Blackbirds, Crows and Faqs.

I want to make it so that any traffic to Albatross/faqs.php, Blackbirds/faqs.php, Crows/faqs.php etc will see the file that is at faqs/faqs.php?bird=albatross or faqs/faqs.php?bird=crows or what have you.

If I go into the Albatross folder's .htaccess file 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 that works for all of them, so 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 various others but nothing seems to work, when I go to http://www.birdsandwhatnot.com/albatross/faqs.php I see the same file the same way it's always been. Does the presence of an .htaccess file in the subfolder conflict with the higher up .htaccess file?

Am I missing something?

Upvotes: 4

Views: 5785

Answers (1)

Pablo
Pablo

Reputation: 29519

A small correction should do the trick

RewriteEngine on

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

"/" is not being passed to parser.

Hope it helps

Upvotes: 2

Related Questions