tags:

views:

22

answers:

1

Currently this is my .htaccess

RewriteEngine on
#rewrite the url's
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

So, from the index i render a template, and give it a url.

Normally a page would look like this www.whatever.com/?url=test/page

But with the rewrite it goes www.whatever.com/test/page

So the question is {

I have an admin section of the site that I want unaffected by this. So, /admin needs to access the admin folder in the folder tree. Thanks for the help

-Wes

+2  A: 

The best way to do this is to not re-write the URL's of real files and directories on the filesystem. This can be achieved by adding a couple rewrite conditions to your rule:

RewriteCond %{REQUEST_FILENAME} !-s [OR]
RewriteCond %{REQUEST_FILENAME} !-l [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

Now, these mean, respectively, only rewrite urls that are: not a real file (with > 0 size), not a symlink, and not a directory.

Alternatively, you could just make sure your rule does not match your admin directory:

RewriteCond  %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

The first example is by far the most flexible, however, as it won't interfere with any static files, such as images, etc.

jason