Topic: mod_rewrite not fully working.

This is the bit of my .htaccess which matters, in the root directory:

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^(.*) /thatDirectory/index.php?invalidDir=$1

If somebody goes to www.example.com/images, it goes to images okey.

If somebody goes to www.example.com/thisDirectory/, while "thisDirectory" does not exist, it should forward to "www.example.com/thatDirectory". The name of the directory that doesnt exist should be passed to the page via a HTTP_GET_VARS variable.

At the moment, it forwards and reads files in "thatDirectory", which exist, but when it needs to reference things like style.css and images, they dont work.

I think, this is because the script is coming from "www.example.com/thatDirectory", I think that reqresite files, like .css, images and etc, are being referenced by "www.example.com/thisDirectory" (which does not exist).

Hope that all makes sense. Thanks.

2

Re: mod_rewrite not fully working.

Nope, it doesn't... smile

What is your exact problem?
If it's the images and such not loading when you request "thatDirectory", that's because they are being
rewritten to your index.php...

Re: mod_rewrite not fully working.

The problem is images not working, I think, the cause is that they're being rewritten to a file as you suggested, so I changed it to:

RewriteRule ^(.*) /thatDirectory/?invalidDir=$1

But that didnt work either?

Re: mod_rewrite not fully working.

Surely you would be better playing with the 404 error settings rather than mod_rewrite?

Re: mod_rewrite not fully working.

Sorry, the example kinda complicates things moreso than the real problem. We're using lots of different databases on the same code base. Where www.example.com/blah is the database to be used for www.example.com/code/index.php?database=blah.