Jump to content

.htaccess - don't touch files that actually exist


methomps

Recommended Posts

Hi guys, I'm having a bit of trouble with my .htaccess file.  I have it setup to funnel everything to index.php, but it is not supposed to do this for requests to files that actually exist (like my css).  However, given that some of my session variable tracking page views jumps by 2-6 every page load, I suspect it is not working properly. 

 

What am I doing wrong?

 

RewriteEngine on

 

# Do not rewrite requests for files and directories that exist

# This means you can still place images, javascript, and css

# in /home/youraccount/yourdomain.com/ directory (or sub-directories)

 

RewriteCond %{REQUEST_FILENAME} -f

# RewriteCond %{REQUEST_FILENAME} -d

RewriteRule .* - [last]

 

# Now rewrite every other request to index.php

 

# Sends: http://www.yourdomain.com => http://www.yourdomain.com?__controller=Index&__action=Index&__params=

RewriteRule ^/?$ index.php?__controller=Index&__action=Index&__params= [QSA,L]

 

# Sends: http://www.yourdomain.com/Members => http://www.yourdomain.com/index.php?__controller=Members&__action=Index&__params=

RewriteRule ^([^/]+)/?$ index.php?__controller=$1&__action=Index&__params= [QSA,L]

 

# Sends: http://www.yourdomain.com/Members/List => http://www.yourdomain.com/index.php?__controller=Members&__action=List&__params=

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?__controller=$1&__action=$2&__params= [QSA,L]

 

# Sends: http://www.yourdomain.com/Members/List/Sort/FirstName/Dir/Asc => http://www.yourdomain.com/index.php?__controller=Members&__action=List&__params=Sort/FirstName/Dir/Asc

RewriteRule ^([^/]+)/([^/]+)/(.*)/?$ index.php?__controller=$1&__action=$2&__params=$3 [QSA,L]

 

This code:

 

RewriteCond %{REQUEST_FILENAME} -f

# RewriteCond %{REQUEST_FILENAME} -d

RewriteRule .* - [last]

 

is intended to tell stop execution of any other rules if the file actually exists, but it doesn't appear to be doing that.

  • 3 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.