LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   apache incorrectly handling requests for numeric php filenames...mod_rewrite problem? (https://www.linuxquestions.org/questions/linux-server-73/apache-incorrectly-handling-requests-for-numeric-php-filenames-mod_rewrite-problem-769181/)

sneakyimp 11-14-2009 04:23 PM

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.

bathory 11-14-2009 04:48 PM

Hi,

Can you post the rewrite part of your apache configuration?

sneakyimp 11-14-2009 05:41 PM

If you mean the rewrite rules, there are none! No RewriteConds, no RewriteRules.

bathory 11-15-2009 02:11 AM

Quote:

Originally Posted by sneakyimp (Post 3757283)
If you mean the rewrite rules, there are none! No RewriteConds, no RewriteRules.

Are you sure about that? Not even in a .htaccess file?

sneakyimp 11-16-2009 04:14 PM

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?

bathory 11-16-2009 04:17 PM

Hi,

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

Regards

sneakyimp 11-16-2009 06:11 PM

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?

bathory 11-17-2009 12:21 AM

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

sneakyimp 11-17-2009 12:30 AM

Excellent link. Thanks very much.


All times are GMT -5. The time now is 11:55 AM.