Page 1 of 1

Mod_rewrite issues

Posted: Thu Jan 20, 2005 1:30 pm
by josh
Trying to design a set of rules to follow, unless the file requested already exists.
Basically I want tutorials/somefile_that_doesnt_exist to be processed by my rules, but /tutorials/file_that_does_exists.php will just bypass my rules

Heres what I've got so far, what it does it it just goes to debug.php and $debug = /tutorials/debug.php

Does this no matter what file I request, even If I just request /

Code: Select all

RewriteEngine on

RewriteCond %{REQUEST_URI} !-f
RewriteRule ^(.*) tutorials/debug.php?debug=%{REQUEST_URI}

Posted: Thu Jan 20, 2005 1:58 pm
by feyd
REQUEST_FILENAME maybe? Might need to use -F instead..

Make sure to use IS_SUBREQ too if you use -F, otherwise you could easily make an infinite recursive loop taking the server down

Posted: Thu Jan 20, 2005 3:32 pm
by josh

Code: Select all

RewriteEngine on
RewriteRule ^tutorials/(.*) tutorials/debug.php?filename=%{REQUEST_FILENAME}&uri=%{REQUES
Requesting tutorials/anything now gives this output:
Filename: /home/only/public_html/webmaster/tutorials/debug.php
Uri: /tutorials/debug.php
For some reason it's displaying the URI that it rewrote to instead of the original URI

Also what is the syntax to say !sub_request or whatever?
I seem to have no problems with mod_rewrite untill I decide to rewrite path_that_already_exists/anything
What is the rule when rewriting from a folder that already exists?

Thanks