views:

70

answers:

1

So if the user types mydomain.com/dashboard, the document the server actually sends them is /launch.php?i=/dashboard.

The one caveat is that I would like to leave requests for

  • /flags
  • /people
  • /posters
  • /css
  • /icons
  • /images
  • /libraries
  • /patterns

alone, and they should request the actual folder.

How would I create such a mod_rewrite?

+5  A: 

This is the .htaccess file for the CakePHP Framework.

Please replace the index.php and ?url= to fit your needs.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

The "!-d" tells Apache to follow existing folders and "!-f" to follow existing files.

Everything else is channelled through index.php

As suggested in a comment, you have to be aware that if it's not working it could be because mod_rewrite is not enabled and you'll not get an error stating that fact, you'll probably only have a HTTP 404.

Gustavo Carreno
<IfModule > is bad practice. Your application will silently fail if you don't have mod_rewrite enabled isntead of throwing a big bad error that would make you fix it immediately.
Vinko Vrsalovic