Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Starting with something as simple as:

RewriteRule ^(.*)$ index.php?page=$1

What if I also want the following to work:

RewriteRule ^/foo$ /index.php?page=foo #/foo IS a directory

This seem to work ONLY if the R flag is set, but then the full non-pretty url is written. Thus it seems I can REDIRECT existing directory, but not rewrite them... Maybe with an .htaccess inside the directory itself? Or some PHP magic in /foo/index.php like header(/index.php?page=foo)? Will it work? Will it be HTTP standard/search engine optimized?

Please help!

PS: The oddest idea occurred to me: redirecting /foo to /not-a-dir, and then rewriting /not-a-dir to /index.php?p=foo should theorically work... But... Come on... Really?!?

share|improve this question
    
why do you need the /foo directory anyway ? are there any content inside you need to access by url such /foo/something ? –  m0ntassar Dec 17 '12 at 10:06

1 Answer 1

There's an option to mod_rewrite to make it handle directories instead of passing them to mod_dir:

RewriteOptions AllowNoSlash

There's more information about this at the apache documentation site.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.