Re: Checking if file or directory exist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux