LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-14-2009, 04:23 PM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
apache incorrectly handling requests for numeric php filenames...mod_rewrite problem?


I'm working on a thorny mod_rewrite problem. I have a mac connected to my LAN running MAMP (Mac/Apache/MySQL/PHP).

I request a non-existent file:
Code:
http://192.168.1.2:8888/careers/db/1.html
I see this in the mod_rewrite log file:
Code:
192.168.1.102 - - [14/Nov/2009:13:46:07 --0800] [192.168.1.2/sid#807df8][rid#8ec850/initial] (2) init rewrite engine with requested uri /careers/db/1.html
192.168.1.102 - - [14/Nov/2009:13:46:07 --0800] [192.168.1.2/sid#807df8][rid#8ec850/initial] (1) pass through /careers/db/1.html
Note that the requested uri is /careers/db/1.html

If I change just the file extension on my request to PHP like so:
Code:
http://192.168.1.2:8888/careers/db/1.php
Then the request uri is totally different now. Here's the rewrite log:
Code:
192.168.1.102 - - [14/Nov/2009:13:47:23 --0800] [192.168.1.2/sid#807df8][rid#8fc850/initial] (2) init rewrite engine with requested uri /Applications/MAMP/htdocs/careers/
192.168.1.102 - - [14/Nov/2009:13:47:23 --0800] [192.168.1.2/sid#807df8][rid#8fc850/initial] (1) pass through /Applications/MAMP/htdocs/careers/
Note that the requested uri now has a full path which does not include the actual filename, /Applications/MAMP/htdocs/careers/

What the heck?

More info. If I request http://192.168.1.2:8888/careers/db/p1.php, I can actually access p1.php. The requested uri is /careers/db/p1.php.

The problem appears to be because the filename starts with a number. I can also request http://192.168.1.2:8888/careers/db//1.php and get thru to 1.php with requested uri /careers/db//1.php.

This seems like a bug to me. Does mod_rewrite think /1 refers to a backreference or something?? Why can apache handle the html file request properly and not the php file request? This is very very annoying. I hope I'm not missing something obvious here.
 
Old 11-14-2009, 04:48 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,158
Blog Entries: 1

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Hi,

Can you post the rewrite part of your apache configuration?
 
Old 11-14-2009, 05:41 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
If you mean the rewrite rules, there are none! No RewriteConds, no RewriteRules.
 
Old 11-15-2009, 02:11 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,158
Blog Entries: 1

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Quote:
Originally Posted by sneakyimp View Post
If you mean the rewrite rules, there are none! No RewriteConds, no RewriteRules.
Are you sure about that? Not even in a .htaccess file?
 
Old 11-16-2009, 04:14 PM   #5
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
I did a grep on the apache conf files and there are no RewriteCond or RewriteRule directives in any of them (except a backup file which does not get evaluated by apache). Likewise, there is no htaccess file in the directory in question nor its parent (which is the web root). I've since rebooted and it appears to be behaving normally now.

I'm wondering if this might be some kind of caching behavior?? It ruined an entire afternoon of attempts to work on a complex rewrite scheme. I ended up working on this on the live server which makes me really nervous -- what if there's a bug in my RewriteMap program? Does apache ever cache mod_rewrite results?
 
Old 11-16-2009, 04:17 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,158
Blog Entries: 1

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Hi,

apache does not cache requests, unless it works as a proxy.
Most likely it was your browser.

Regards
 
Old 11-16-2009, 06:11 PM   #7
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
I've been looking at my options in firefox and can't seem to find any cache-related options. I really need to disable this type of caching. Any thoughts?
 
Old 11-17-2009, 12:21 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,158
Blog Entries: 1

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
If you want to disable cache in firefox read this.
I prefer use "Shift-Reload" in browser, when I want to test changes in apache config or in web pages.

Regards
 
Old 11-17-2009, 12:30 AM   #9
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Excellent link. Thanks very much.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple apache mod_rewrite problem (newbie) rtnylw Linux - Server 7 08-08-2009 11:38 AM
problem with apache mod_rewrite nephish Linux - Software 0 01-22-2007 08:57 AM
Apache virtual hosts and mod_rewrite problem Gyper Debian 3 07-31-2006 11:22 PM
command line handling folder/filenames Basslord1124 Linux - Newbie 1 03-25-2005 09:43 AM
Handling filenames with spaces in PHP gw1500se Programming 2 03-14-2004 01:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration