Mod_rewrite pretty url when domain/foo is a directory
- by ModRewriter
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?!?