Welcome to WebmasterWorld Guest from 62.210.77.51

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess RewriteCond working badly

RewriteCond %{REQUEST_FILENAME} !-f finds files that really dont exist

     
8:58 pm on Nov 18, 2006 (gmt 0)

New User

10+ Year Member

joined:Nov 18, 2006
posts:2
votes: 0


Hello

I am using an Apache server and a .htaccess file with these lines:

<Files *.inc>
Deny from all
</Files>
RewriteEngine On
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^(.*)$ handle_requests.php [L]

When I try to navigate to the address [my.server.com...] based on the rewrite rules it should call handle_requests.php to handle the request, because there isnt any "index" file. This is very strange... I am suspicious that it has something with an existing file "index.inc".

error.log:
[Sat Nov 18 21:07:25 2006] [error] [client 192.168.1.128] client denied by server configuration: /www/default/public_html/mysite/index.inc

[Sat Nov 18 21:07:25 2006] [error] [client 192.168.1.128] Negotiation: discovered file(s) matching request: /www/default/public_html/mysite/index (None could be negotiated).

Can someone advise me a solution?

Thanks.

My server: Apache/2.0.54 (Debian GNU/Linux) PHP/5.2.0-0.dotdeb.3 with Suhosin-Patch Server at my.server.com Port 80

PS. The "my.server.com" and "/mysite/" are just imaginative. The originals match accurately their format.

11:30 pm on Nov 18, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Sounds like you may have MultiViews/content-negotiation enabled, which will grab the URL and try to find a "best match" to the requested URL. In the absense of a better, closer match, it will choose "index.inc" as a match for "index". This of course interferes with your file-exists test and rule.

Try preceding your code with


Options -MultiViews

to disable it and see if that helps.

If you already have an Options statement like "Options +FollowSymLinks -Indexes" in your code, you can add "-MultiViews" to the end of that line, so you get something like


Options +FollowSymLinks -Indexes -MultiViews

Jim
10:25 am on Nov 19, 2006 (gmt 0)

New User

10+ Year Member

joined:Nov 18, 2006
posts:2
votes: 0


Thanks jdMorgan!

That really worked for me...