1

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?!?

  • 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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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