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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.