Jump to content

mod_rewrite preventing default index page access


Recommended Posts

Hi all

 

Could someone please help me understand what's going on here.

 

I would like the last rules of my config to pass the full url to a script that looks it up in a database to find the page that should be displayed. So I have the following rules:

 

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

 

RewriteRule ^([a-z0-9-/]+)/$ /index.php?c=page&url=/$1 [L]

RewriteRule ^([a-z0-9-/]+)$ /index.php?c=page&url=/$1 [L]

 

I put two lines here because I couldn't work out how to make /test/test and /test/test/ (with trailing slash) result in $1 being /test/test (no trailing slash) so that the database lookup works consistently. Anyway, if I create a directory called "example" with a default "index.html" file there and access it by going to /example, Apache tries processes the bottom two RewriteRules rather than getting the default index file. Very annoying and can't seem to find a way around this. I tried looking this up but haven't had much luck. Tried using the NS switch too on those lines to no avail.

 

I am using Apache version 2.2.6.

 

Any help greatly appreciated.

 

Thanks

 

Jamie.

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.