Forum Moderators: phranque

Message Too Old, No Replies

Virtual folders problem

Problem with accessing exisiting pages/directories

         

mwalther

11:15 am on Feb 18, 2007 (gmt 0)

10+ Year Member



Hi!

I'm trying to forward all requests for non-exisiting pages/directories to mypage.php. This, in order to allow virtual directories like mydomain.com/animals/cats even though /animals/cats does not exist.

I got the following code :

Options +FollowSymLinks
RewriteEngine on
rewritecond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-f
rewritecond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-d
RewriteRule . /mypage.php

(I was told this is better than using ErrorDocument)

It works a bit too well. Now EVERYTHING is sent to mypage.php, even though if i try to access a file or directory which exists.

Please advice!

markus

jdMorgan

3:24 pm on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



REQUEST_FILENAME will almost always include DOCUMENT_ROOT, so including DOCUMENT_ROOT in your RewriteConds is both redundant and liable to break your RewriteCond logic. Try:

Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mypage.php [L]

Jim