You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jason Pruim <ja...@raoset.com> on 2008/09/10 17:54:10 UTC

[users@httpd] Checking if file or directory exist

Hello everyone,

So I'm still fighting with mod_rewrite a little but I have made  
progress... Basically, what I am looking to do now, is check to see if  
a file/folder exists and if not rewrite and give control to my p.php  
script to look it up in the database.

Here are the rules that I'm using:

		RewriteCond %{REQUEST_FILENAME} !-f
                 RewriteCond %{REQUEST_FILENAME} !-d
                 RewriteRule . /p.php [L]

Now, that part works just fine, but what I can't seem to work out is  
the sublinks. I have some links that look like this: HTTP://purl.schreurprinting.com/mail.php?purl=jasonpruim112 
  Now mail.php exists and so it should NOT be rewriting, but it is...  
Basically... If someone goes to mail.php?purl=jasonpruim112 I want  
mail.php to handle the request... Am I making sense?

Anyone have any clue what I need to do?

Thanks for looking!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Justin Pasher <ju...@newmediagateway.com>.
Jason Pruim wrote:
>>>>> RewriteRule . /p.php [L]
>>>> RewriteCond %{REQUEST_FILENAME} !-f
>>>>
>>>> You're not capturing or passing anything, and how do you get to 
>>>> mail.php?
>>>
>>> after you load purl.schreurprinting.com/jasonpruim112 there will be 
>>> a link to http://purl.schreurprinting.com/mail.php?purl=jasonpruim112
>>>
>>> The basic premise I have been working off of is just simply if the 
>>> file exists, let that file handle serving the page, if it DOESN"T 
>>> exist pass it to p.php to handle it.
>>>
>>> So with that understanding I don't think that I need to capture 
>>> anything in the rewritecond's other then if the file exists correct?
>> RewriteCond %{REQUEST_FILENAME} !-d
>>
>> You shouldn't have to worry about capturing any query string since 
>> you are performing an internal rewrite (the URL stays the same for 
>> the user). Referring back to your other email (which I mistakenly 
>> nuked already)...
>>
>> --------------------
>> That is odd.... I moved the rewrite rules to a .htaccess file and now 
>> the real links work right, but the false links don't go into my 
>> handeler script... in other words 
>> http://purl.schreurprinting.com/mail.php?purl=jasonpruim112 works but 
>> http://purl.schreurprinting.com/jasonpruim112 does NOT...
>>
>> Here is my .htaccess file... Does it look right?
>>
>> Options +FollowSymlinks
>> RewriteEngine on
>> RewriteLog /var/log/purl.virt.rewrite.log
>> RewriteLogLevel 9
>>
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteRule . /p.php [L]
>> --------------------
>>
>> So there is no file/directory called jasonpruim112 
>> <http://purl.schreurprinting.com/jasonpruim112>, correct? I copied 
>> your .htaccess file (removing the RewriteLog* references) and it 
>> correctly rewrites the URL request for /jasonpruim112 
>> <http://purl.schreurprinting.com/jasonpruim112> to p.php. Is this not 
>> what you are seeing?
>
> Hey Justin,
>
> You are correct that jasonpruim112 does not exist but is linked in a 
> database... Although, I did some searching on the net and fighting 
> with my config files and noticed that AllowOverides was set to none 
> rather then all....
>
> Once I made that switch both the main link, and the internal links all 
> started working properly.
>
> Sometimes I hate how picky computers can be hehehe.

Doh. I forgot to mention that moving to the .htaccess file would require 
apache to allow overrides in that directory. That was my default setting 
in my testing environment, so I didn't even think of it. If all else 
fails, I find checking the apache error log can sometimes reveal things 
that you may not have known were going wrong.

At any rate, it sounds like you're all set now!

-- 
Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Jason Pruim <ja...@raoset.com>.
On Sep 11, 2008, at 11:14 AM, Justin Pasher wrote:

> Jason Pruim wrote:
>> On Sep 11, 2008, at 7:30 AM, Eric Covener wrote:
>>
>>> On Thu, Sep 11, 2008 at 6:28 AM, Jason Pruim <ja...@raoset.com>  
>>> wrote:
>>>
>>>> Here is my .htaccess file... Does it look right?
>>>>
>>>> Options +FollowSymlinks
>>>> RewriteEngine on
>>>> RewriteLog /var/log/purl.virt.rewrite.log
>>>
>>> is this valdi in .htaccess?
>>
>> My guess is no since it's not working...
>
> Log directives cannot be used in .htaccess files (it could be a  
> potential security hole to allow a user to specify their own logs,  
> hammer the site with requests, then fill up a partition). Normally  
> you would receive a 500 error code and a message in the apache error  
> logging stating the directory is not allowed. You can, however, just  
> leave it in the global/virtualhost apache config.
>
>>>> RewriteLogLevel 9
>>>>
>>>
>>> where's RewriteBase?
>>
>> I thought that rewritebase was optional?
>
> It is optional. It all depends on your setup/usage as to whether you  
> need to use it.
>
>>>> RewriteCond %{REQUEST_FILENAME} !-d
>>>> RewriteRule . /p.php [L]
>>> RewriteCond %{REQUEST_FILENAME} !-f
>>>
>>> You're not capturing or passing anything, and how do you get to  
>>> mail.php?
>>
>> after you load purl.schreurprinting.com/jasonpruim112 there will be  
>> a link to http://purl.schreurprinting.com/mail.php?purl=jasonpruim112
>>
>> The basic premise I have been working off of is just simply if the  
>> file exists, let that file handle serving the page, if it DOESN"T  
>> exist pass it to p.php to handle it.
>>
>> So with that understanding I don't think that I need to capture  
>> anything in the rewritecond's other then if the file exists correct?
>
> You shouldn't have to worry about capturing any query string since  
> you are performing an internal rewrite (the URL stays the same for  
> the user). Referring back to your other email (which I mistakenly  
> nuked already)...
>
> --------------------
> That is odd.... I moved the rewrite rules to a .htaccess file and  
> now the real links work right, but the false links don't go into my  
> handeler script... in other words http://purl.schreurprinting.com/mail.php?purl=jasonpruim112 
>  works but http://purl.schreurprinting.com/jasonpruim112 does NOT...
>
> Here is my .htaccess file... Does it look right?
>
> Options +FollowSymlinks
> RewriteEngine on
> RewriteLog /var/log/purl.virt.rewrite.log
> RewriteLogLevel 9
>
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule . /p.php [L]
> --------------------
>
> So there is no file/directory called jasonpruim112 <http://purl.schreurprinting.com/jasonpruim112 
> >, correct? I copied your .htaccess file (removing the RewriteLog*  
> references) and it correctly rewrites the URL request for / 
> jasonpruim112 <http://purl.schreurprinting.com/jasonpruim112> to  
> p.php. Is this not what you are seeing?

Hey Justin,

You are correct that jasonpruim112 does not exist but is linked in a  
database... Although, I did some searching on the net and fighting  
with my config files and noticed that AllowOverides was set to none  
rather then all....

Once I made that switch both the main link, and the internal links all  
started working properly.

Sometimes I hate how picky computers can be hehehe.


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Justin Pasher <ju...@newmediagateway.com>.
Jason Pruim wrote:
> On Sep 11, 2008, at 7:30 AM, Eric Covener wrote:
>
>> On Thu, Sep 11, 2008 at 6:28 AM, Jason Pruim <ja...@raoset.com> wrote:
>>
>>> Here is my .htaccess file... Does it look right?
>>>
>>> Options +FollowSymlinks
>>> RewriteEngine on
>>> RewriteLog /var/log/purl.virt.rewrite.log
>>
>> is this valdi in .htaccess?
>
> My guess is no since it's not working...

Log directives cannot be used in .htaccess files (it could be a 
potential security hole to allow a user to specify their own logs, 
hammer the site with requests, then fill up a partition). Normally you 
would receive a 500 error code and a message in the apache error logging 
stating the directory is not allowed. You can, however, just leave it in 
the global/virtualhost apache config.

>>> RewriteLogLevel 9
>>>
>>
>> where's RewriteBase?
>
> I thought that rewritebase was optional?

It is optional. It all depends on your setup/usage as to whether you 
need to use it.

>>> RewriteCond %{REQUEST_FILENAME} !-d
>>> RewriteRule . /p.php [L]
>> RewriteCond %{REQUEST_FILENAME} !-f
>>
>> You're not capturing or passing anything, and how do you get to 
>> mail.php?
>
> after you load purl.schreurprinting.com/jasonpruim112 there will be a 
> link to http://purl.schreurprinting.com/mail.php?purl=jasonpruim112
>
> The basic premise I have been working off of is just simply if the 
> file exists, let that file handle serving the page, if it DOESN"T 
> exist pass it to p.php to handle it.
>
> So with that understanding I don't think that I need to capture 
> anything in the rewritecond's other then if the file exists correct?

You shouldn't have to worry about capturing any query string since you 
are performing an internal rewrite (the URL stays the same for the 
user). Referring back to your other email (which I mistakenly nuked 
already)...

--------------------
That is odd.... I moved the rewrite rules to a .htaccess file and now 
the real links work right, but the false links don't go into my handeler 
script... in other words 
http://purl.schreurprinting.com/mail.php?purl=jasonpruim112 works but 
http://purl.schreurprinting.com/jasonpruim112 does NOT...

Here is my .htaccess file... Does it look right?

Options +FollowSymlinks
RewriteEngine on
RewriteLog /var/log/purl.virt.rewrite.log
RewriteLogLevel 9

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /p.php [L]
--------------------

So there is no file/directory called jasonpruim112 
<http://purl.schreurprinting.com/jasonpruim112>, correct? I copied your 
.htaccess file (removing the RewriteLog* references) and it correctly 
rewrites the URL request for /jasonpruim112 
<http://purl.schreurprinting.com/jasonpruim112> to p.php. Is this not 
what you are seeing?


-- 
Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Jason Pruim <ja...@raoset.com>.
On Sep 11, 2008, at 7:30 AM, Eric Covener wrote:

> On Thu, Sep 11, 2008 at 6:28 AM, Jason Pruim <ja...@raoset.com>  
> wrote:
>
>> Here is my .htaccess file... Does it look right?
>>
>> Options +FollowSymlinks
>> RewriteEngine on
>> RewriteLog /var/log/purl.virt.rewrite.log
>
> is this valdi in .htaccess?

My guess is no since it's not working...

>
>
>> RewriteLogLevel 9
>>
>
> where's RewriteBase?

I thought that rewritebase was optional?
>
>
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteRule . /p.php [L]
>
> You're not capturing or passing anything, and how do you get to  
> mail.php?

after you load purl.schreurprinting.com/jasonpruim112 there will be a  
link to http://purl.schreurprinting.com/mail.php?purl=jasonpruim112

The basic premise I have been working off of is just simply if the  
file exists, let that file handle serving the page, if it DOESN"T  
exist pass it to p.php to handle it.

So with that understanding I don't think that I need to capture  
anything in the rewritecond's other then if the file exists correct?

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Eric Covener <co...@gmail.com>.
On Thu, Sep 11, 2008 at 6:28 AM, Jason Pruim <ja...@raoset.com> wrote:

> Here is my .htaccess file... Does it look right?
>
> Options +FollowSymlinks
> RewriteEngine on
> RewriteLog /var/log/purl.virt.rewrite.log

is this valdi in .htaccess?

> RewriteLogLevel 9
>

where's RewriteBase?

> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule . /p.php [L]

You're not capturing or passing anything, and how do you get to mail.php?

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Jason Pruim <ja...@raoset.com>.
On Sep 10, 2008, at 2:21 PM, Justin Pasher wrote:

> Jason Pruim wrote:
>>
>> On Sep 10, 2008, at 1:38 PM, Justin Pasher wrote:
>>
>>> Jason Pruim wrote:
>>>> Actually it is... It was something that I tried to fix the  
>>>> problem. All the links refer to /mail.php though...
>>>>
>>>> BEGIN LOG
>>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>>>> init rewrite engine with requested uri /mail.php
>>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3)  
>>>> applying pattern '.' to uri '/mail.php'
>>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
>>>> RewriteCond: input='/mail.php' pattern='!-f' => matched
>>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
>>>> RewriteCond: input='/mail.php' pattern='!-d' => matched
>>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>>>> rewrite /mail.php -> /p.php
>>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>>>> local path result: /p.php
>>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>>>> prefixed with document_root to /Volumes/RAIDer/webserver/ 
>>>> purl.schreurprinting.com/p.php
>>>>
>>>> Also here is my directory structure...
>>>>
>>>> qs:/etc/httpd/sites japruim$ ls /volumes/raider/webserver/ 
>>>> purl.schreurprinting.com
>>>> build <----Folder
>>>> design.php
>>>> inc
>>>> index.php
>>>> mail.php
>>>> p.php
>>>> php.ini.php
>>>> pictures
>>>> print.php
>>>> purl <----Folder
>>>> purl.php
>>>> purl.schreurprinting.com.xcodeproj <----Folder
>>>> purlprocess.php
>>>> qs:/etc/httpd/sites japruim$
>>>
>>> What does the rewrite log entry look like when you try to just  
>>> access http://purl.schreurprinting.com/mail.php (without the query  
>>> string)?
>>>
>>> I noticed that the input for the write rule is "/mail.php" (as  
>>> opposed to /volumes/raider/webserver/purl.schreurprinting.com/ 
>>> mail.php). Since that file really doesn't exist, it fails the file  
>>> test. This might be due to the differences in rewrite rules in the  
>>> apache config versus .htaccess. Do you have a RewriteBase set in  
>>> the config? It looks like %{REQUEST_FILENAME} is not being  
>>> evaluated to the full path of the file. I haven't had a chance to  
>>> test myself in a VirtualHost config setup.
>>
>>
>> Here is the log for just http://purl.scherurprinting.com/mail.php
>> BEGIN LOG
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> init rewrite engine with requested uri /mail.php
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3)  
>> applying pattern '.' to uri '/mail.php'
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
>> RewriteCond: input='/mail.php' pattern='!-f' => matched
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
>> RewriteCond: input='/mail.php' pattern='!-d' => matched
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> rewrite /mail.php -> /p.php
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> local path result: /p.php
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> prefixed with document_root to /Volumes/RAIDer/webserver/ 
>> purl.schreurprinting.com/p.php
>> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (1) go- 
>> ahead with /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php  
>> [OK]
>>
>>
>> But /volumes/raider/webserver/purl.schreurprinting.com/mail.php is  
>> valid... that is the entire file system path... but it's there :)
>>
>> Would this be easier to setup in a .htaccess file?
>
> According to this log, the request to just http://purl.scherurprinting.com/mail.php 
>  is also being rewritten now...? Wasn't this one working before (in  
> the initial email)?
>
> I did a quick test inside a VirtualHost instead of .htaccess and,  
> sure enough, the %{REQUEST_FILENAME} became just "/mail.php". It  
> looks like Apache is stripping off the DocumentRoot from % 
> {REQUEST_FILENAME} when used in the apache config. Try moving the  
> rewrite settings to an .htaccess file and see what the log shows  
> (especially for the "input=" line). If it works, and it is a  
> feasible solution, I'd go that route. It also allows you to modify  
> the rewrite rules without forcing an apache reload.


That is odd.... I moved the rewrite rules to a .htaccess file and now  
the real links work right, but the false links don't go into my  
handeler script... in other words http://purl.schreurprinting.com/mail.php?purl=jasonpruim112 
  works but http://purl.schreurprinting.com/jasonpruim112 does NOT...

Here is my .htaccess file... Does it look right?

Options +FollowSymlinks
RewriteEngine on
RewriteLog /var/log/purl.virt.rewrite.log
RewriteLogLevel 9

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /p.php [L]

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Justin Pasher <ju...@newmediagateway.com>.
Jason Pruim wrote:
>
> On Sep 10, 2008, at 1:38 PM, Justin Pasher wrote:
>
>> Jason Pruim wrote:
>>> Actually it is... It was something that I tried to fix the problem. 
>>> All the links refer to /mail.php though...
>>>
>>> BEGIN LOG
>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init 
>>> rewrite engine with requested uri /mail.php
>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3) 
>>> applying pattern '.' to uri '/mail.php'
>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4) 
>>> RewriteCond: input='/mail.php' pattern='!-f' => matched
>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4) 
>>> RewriteCond: input='/mail.php' pattern='!-d' => matched
>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) 
>>> rewrite /mail.php -> /p.php
>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) 
>>> local path result: /p.php
>>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) 
>>> prefixed with document_root to 
>>> /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php
>>>
>>> Also here is my directory structure...
>>>
>>> qs:/etc/httpd/sites japruim$ ls 
>>> /volumes/raider/webserver/purl.schreurprinting.com
>>> build <----Folder
>>> design.php
>>> inc
>>> index.php
>>> mail.php
>>> p.php
>>> php.ini.php
>>> pictures
>>> print.php
>>> purl <----Folder
>>> purl.php
>>> purl.schreurprinting.com.xcodeproj <----Folder
>>> purlprocess.php
>>> qs:/etc/httpd/sites japruim$
>>
>> What does the rewrite log entry look like when you try to just access 
>> http://purl.schreurprinting.com/mail.php (without the query string)?
>>
>> I noticed that the input for the write rule is "/mail.php" (as 
>> opposed to 
>> /volumes/raider/webserver/purl.schreurprinting.com/mail.php). Since 
>> that file really doesn't exist, it fails the file test. This might be 
>> due to the differences in rewrite rules in the apache config versus 
>> .htaccess. Do you have a RewriteBase set in the config? It looks like 
>> %{REQUEST_FILENAME} is not being evaluated to the full path of the 
>> file. I haven't had a chance to test myself in a VirtualHost config 
>> setup.
>
>
> Here is the log for just http://purl.scherurprinting.com/mail.php
> BEGIN LOG
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init 
> rewrite engine with requested uri /mail.php
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3) 
> applying pattern '.' to uri '/mail.php'
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4) 
> RewriteCond: input='/mail.php' pattern='!-f' => matched
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4) 
> RewriteCond: input='/mail.php' pattern='!-d' => matched
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) 
> rewrite /mail.php -> /p.php
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) local 
> path result: /p.php
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) 
> prefixed with document_root to 
> /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php
> 192.168.0.253 - - [10/Sep/2008:13:40:25 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (1) 
> go-ahead with /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php 
> [OK]
>
>
> But /volumes/raider/webserver/purl.schreurprinting.com/mail.php is 
> valid... that is the entire file system path... but it's there :)
>
> Would this be easier to setup in a .htaccess file?

According to this log, the request to just 
http://purl.scherurprinting.com/mail.php is also being rewritten now...? 
Wasn't this one working before (in the initial email)?

I did a quick test inside a VirtualHost instead of .htaccess and, sure 
enough, the %{REQUEST_FILENAME} became just "/mail.php". It looks like 
Apache is stripping off the DocumentRoot from %{REQUEST_FILENAME} when 
used in the apache config. Try moving the rewrite settings to an 
.htaccess file and see what the log shows (especially for the "input=" 
line). If it works, and it is a feasible solution, I'd go that route. It 
also allows you to modify the rewrite rules without forcing an apache 
reload.


-- 
Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Jason Pruim <ja...@raoset.com>.
On Sep 10, 2008, at 1:38 PM, Justin Pasher wrote:

> Jason Pruim wrote:
>>
>> On Sep 10, 2008, at 1:24 PM, Eric Covener wrote:
>>
>>>> . I have some links that look like this: HTTP://purl.schreurprinting.com/mail.php?purl=jasonpruim112
>>> ...
>>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>>>> init rewrite
>>>> engine with requested uri /purl/mail.php
>>>
>>> Maybe mail.php is under your docroot, but purl/mail.php isn't.
>>
>> Actually it is... It was something that I tried to fix the problem.  
>> All the links refer to /mail.php though...
>>
>> BEGIN LOG
>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> init rewrite engine with requested uri /mail.php
>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3)  
>> applying pattern '.' to uri '/mail.php'
>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
>> RewriteCond: input='/mail.php' pattern='!-f' => matched
>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
>> RewriteCond: input='/mail.php' pattern='!-d' => matched
>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> rewrite /mail.php -> /p.php
>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> local path result: /p.php
>> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> prefixed with document_root to /Volumes/RAIDer/webserver/ 
>> purl.schreurprinting.com/p.php
>>
>> Also here is my directory structure...
>>
>> qs:/etc/httpd/sites japruim$ ls /volumes/raider/webserver/ 
>> purl.schreurprinting.com
>> build <----Folder
>> design.php
>> inc
>> index.php
>> mail.php
>> p.php
>> php.ini.php
>> pictures
>> print.php
>> purl <----Folder
>> purl.php
>> purl.schreurprinting.com.xcodeproj <----Folder
>> purlprocess.php
>> qs:/etc/httpd/sites japruim$
>
> What does the rewrite log entry look like when you try to just  
> access http://purl.schreurprinting.com/mail.php (without the query  
> string)?
>
> I noticed that the input for the write rule is "/mail.php" (as  
> opposed to /volumes/raider/webserver/purl.schreurprinting.com/ 
> mail.php). Since that file really doesn't exist, it fails the file  
> test. This might be due to the differences in rewrite rules in the  
> apache config versus .htaccess. Do you have a RewriteBase set in the  
> config? It looks like %{REQUEST_FILENAME} is not being evaluated to  
> the full path of the file. I haven't had a chance to test myself in  
> a VirtualHost config setup.


Here is the log for just http://purl.scherurprinting.com/mail.php
BEGIN LOG
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init  
rewrite engine with requested uri /mail.php
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3)  
applying pattern '.' to uri '/mail.php'
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/mail.php' pattern='!-f' => matched
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/mail.php' pattern='!-d' => matched
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
rewrite /mail.php -> /p.php
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) local  
path result: /p.php
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
prefixed with document_root to /Volumes/RAIDer/webserver/ 
purl.schreurprinting.com/p.php
192.168.0.253 - - [10/Sep/2008:13:40:25 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (1) go- 
ahead with /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php [OK]


But /volumes/raider/webserver/purl.schreurprinting.com/mail.php is  
valid... that is the entire file system path... but it's there :)

Would this be easier to setup in a .htaccess file?


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Justin Pasher <ju...@newmediagateway.com>.
Jason Pruim wrote:
>
> On Sep 10, 2008, at 1:24 PM, Eric Covener wrote:
>
>>> . I have some links that look like this: 
>>> HTTP://purl.schreurprinting.com/mail.php?purl=jasonpruim112
>> ...
>>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init 
>>> rewrite
>>> engine with requested uri /purl/mail.php
>>
>> Maybe mail.php is under your docroot, but purl/mail.php isn't.
>
> Actually it is... It was something that I tried to fix the problem. 
> All the links refer to /mail.php though...
>
> BEGIN LOG
> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init 
> rewrite engine with requested uri /mail.php
> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3) 
> applying pattern '.' to uri '/mail.php'
> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4) 
> RewriteCond: input='/mail.php' pattern='!-f' => matched
> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4) 
> RewriteCond: input='/mail.php' pattern='!-d' => matched
> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) 
> rewrite /mail.php -> /p.php
> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) local 
> path result: /p.php
> 192.168.0.253 - - [10/Sep/2008:13:28:26 -0400] 
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) 
> prefixed with document_root to 
> /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php
>
> Also here is my directory structure...
>
> qs:/etc/httpd/sites japruim$ ls 
> /volumes/raider/webserver/purl.schreurprinting.com
> build <----Folder
> design.php
> inc
> index.php
> mail.php
> p.php
> php.ini.php
> pictures
> print.php
> purl <----Folder
> purl.php
> purl.schreurprinting.com.xcodeproj <----Folder
> purlprocess.php
> qs:/etc/httpd/sites japruim$ 

What does the rewrite log entry look like when you try to just access 
http://purl.schreurprinting.com/mail.php (without the query string)?

I noticed that the input for the write rule is "/mail.php" (as opposed 
to /volumes/raider/webserver/purl.schreurprinting.com/mail.php). Since 
that file really doesn't exist, it fails the file test. This might be 
due to the differences in rewrite rules in the apache config versus 
.htaccess. Do you have a RewriteBase set in the config? It looks like 
%{REQUEST_FILENAME} is not being evaluated to the full path of the file. 
I haven't had a chance to test myself in a VirtualHost config setup.


-- 
Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Jason Pruim <ja...@raoset.com>.
On Sep 10, 2008, at 1:24 PM, Eric Covener wrote:

>> . I have some links that look like this: HTTP://purl.schreurprinting.com/mail.php?purl=jasonpruim112
> ...
>> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
>> init rewrite
>> engine with requested uri /purl/mail.php
>
> Maybe mail.php is under your docroot, but purl/mail.php isn't.

Actually it is... It was something that I tried to fix the problem.  
All the links refer to /mail.php though...

BEGIN LOG
192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init  
rewrite engine with requested uri /mail.php
192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3)  
applying pattern '.' to uri '/mail.php'
192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/mail.php' pattern='!-f' => matched
192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/mail.php' pattern='!-d' => matched
192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
rewrite /mail.php -> /p.php
192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) local  
path result: /p.php
192.168.0.253 - - [10/Sep/2008:13:28:26 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
prefixed with document_root to /Volumes/RAIDer/webserver/ 
purl.schreurprinting.com/p.php

Also here is my directory structure...

qs:/etc/httpd/sites japruim$ ls /volumes/raider/webserver/ 
purl.schreurprinting.com
build <----Folder
design.php
inc
index.php
mail.php
p.php
php.ini.php
pictures
print.php
purl <----Folder
purl.php
purl.schreurprinting.com.xcodeproj <----Folder
purlprocess.php
qs:/etc/httpd/sites japruim$


>
> -- 
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server  
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Eric Covener <co...@gmail.com>.
>. I have some links that look like this: HTTP://purl.schreurprinting.com/mail.php?purl=jasonpruim112
...
> [purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init rewrite
> engine with requested uri /purl/mail.php

Maybe mail.php is under your docroot, but purl/mail.php isn't.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Jason Pruim <ja...@raoset.com>.
On Sep 10, 2008, at 12:36 PM, Justin Pasher wrote:

> Jason Pruim wrote:
>> Hello everyone,
>>
>> So I'm still fighting with mod_rewrite a little but I have made  
>> progress... Basically, what I am looking to do now, is check to see  
>> if a file/folder exists and if not rewrite and give control to my  
>> p.php script to look it up in the database.
>>
>> Here are the rules that I'm using:
>>
>>        RewriteCond %{REQUEST_FILENAME} !-f
>>                RewriteCond %{REQUEST_FILENAME} !-d
>>                RewriteRule . /p.php [L]
>>
>> Now, that part works just fine, but what I can't seem to work out  
>> is the sublinks. I have some links that look like this: HTTP://purl.schreurprinting.com/mail.php?purl=jasonpruim112 
>>  Now mail.php exists and so it should NOT be rewriting, but it  
>> is... Basically... If someone goes to mail.php?purl=jasonpruim112 I  
>> want mail.php to handle the request... Am I making sense?
>>
>> Anyone have any clue what I need to do?
>>
>> Thanks for looking!
>
> I threw together a quick test with the same rewrite rules you  
> mentioned above and it seems to work properly for me. Are these  
> rules defined in an .htaccess file or the apache config? I know that  
> rewrite rules can act a little differently between the two  
> locations. Are there any other rewrite rules being invoked? Can you  
> turn on the rewrite logging to see exactly what mod_rewrite is doing?
>
> RewriteLogLevel 3
> RewriteLog /path/to/rewrite.log
Hey Justin,

Thanks for the reply.

The rules are being applied from a virtual host config, so as high up  
the chain as it can go.

And since I was running into issues, I set the rewrite log up to 9 and  
here is the output that I just got from it:

BEGIN LOG

192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init  
rewrite engine with requested uri /purl/mail.php
192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3)  
applying pattern '.' to uri '/purl/mail.php'
192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/purl/mail.php' pattern='!-f' => matched
192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/purl/mail.php' pattern='!-d' => matched
192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
rewrite /purl/mail.php -> /p.php
192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) local  
path result: /p.php
192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
prefixed with document_root to /Volumes/RAIDer/webserver/ 
purl.schreurprinting.com/p.php
192.168.0.253 - - [10/Sep/2008:12:38:10 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (1) go- 
ahead with /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php [OK]
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) init  
rewrite engine with requested uri /favicon.ico
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (3)  
applying pattern '.' to uri '/favicon.ico'
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/favicon.ico' pattern='!-f' => matched
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (4)  
RewriteCond: input='/favicon.ico' pattern='!-d' => matched
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
rewrite /favicon.ico -> /p.php
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2) local  
path result: /p.php
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (2)  
prefixed with document_root to /Volumes/RAIDer/webserver/ 
purl.schreurprinting.com/p.php
192.168.0.253 - - [10/Sep/2008:12:38:11 -0400]  
[purl.schreurprinting.com/sid#183ecd8][rid#1836238/initial] (1) go- 
ahead with /Volumes/RAIDer/webserver/purl.schreurprinting.com/p.php [OK]




And no, there are no other rules being used that I am aware of.

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Checking if file or directory exist

Posted by Justin Pasher <ju...@newmediagateway.com>.
Jason Pruim wrote:
> Hello everyone,
>
> So I'm still fighting with mod_rewrite a little but I have made 
> progress... Basically, what I am looking to do now, is check to see if 
> a file/folder exists and if not rewrite and give control to my p.php 
> script to look it up in the database.
>
> Here are the rules that I'm using:
>
>         RewriteCond %{REQUEST_FILENAME} !-f
>                 RewriteCond %{REQUEST_FILENAME} !-d
>                 RewriteRule . /p.php [L]
>
> Now, that part works just fine, but what I can't seem to work out is 
> the sublinks. I have some links that look like this: 
> HTTP://purl.schreurprinting.com/mail.php?purl=jasonpruim112 Now 
> mail.php exists and so it should NOT be rewriting, but it is... 
> Basically... If someone goes to mail.php?purl=jasonpruim112 I want 
> mail.php to handle the request... Am I making sense?
>
> Anyone have any clue what I need to do?
>
> Thanks for looking!

I threw together a quick test with the same rewrite rules you mentioned 
above and it seems to work properly for me. Are these rules defined in 
an .htaccess file or the apache config? I know that rewrite rules can 
act a little differently between the two locations. Are there any other 
rewrite rules being invoked? Can you turn on the rewrite logging to see 
exactly what mod_rewrite is doing?

RewriteLogLevel 3
RewriteLog /path/to/rewrite.log


-- 
Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org