Rewrite Confilcts with Existing Files

Oh, the strange things mod_rewrite does!

Rewrite Confilcts with Existing Files

Postby sgarrison » Sat Nov 08, 2008 7:18 pm

I have a file structure like this...


...and so on.

These pages are only snippets that are plugged into the index.php file in my root folder via index.php?cat=dirA&page=page1 etc.

RewriteRule ^([a-z]+)/([a-z]+)$ /index.php?cat=$1&page=$2 [NC]

The idea is that when the user types in, he is redirected to The conflict is that dirA and page1.html actually exist as folder and file. Apache loads page1.html even though the URL doesn't provide the extension and ignores the rewrite rule.

Is there a way to maybe force Apache to ignore files unless the extension is explicit, thereby removing the conflict and processing the rewrite rule?

I know for sure that mod_rewrite works on my server.
Posts: 2
Joined: Sat Nov 08, 2008 7:11 pm

Postby richardk » Sun Nov 09, 2008 11:31 am

It's because of MultiViews.
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^([a-z]+)/([a-z]+)$ /index.php?cat=$1&page=$2 [NC,L]
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Postby sgarrison » Sun Nov 09, 2008 2:11 pm

Great. That made it work. Thanks a bunch!
Posts: 2
Joined: Sat Nov 08, 2008 7:11 pm

Postby Ulysses » Wed Dec 10, 2008 4:18 am

richardk wrote:It's because of MultiViews

Thanks for that, Richard. That is exactly what I was looking for.
Posts: 10
Joined: Thu Sep 18, 2008 7:58 am

Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 1 guest