Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I ran into an unexpected case of Apache giving me a 404 error instead of letting mod_rewrite handle the path, when one of the percent-encoded path parts was itself a HTTP URL.

e.g. "GET /myfolder/http%3A%2F%2Flocalhost%2Fnotify HTTP/1.0"

I have an extremely simple rule in the /myfolder/.htaccess file which sends everything that's not a file in /myfolder/ to a script. It works fine with other percent-encoded values, but in this case Apache never processes the RewriteRule from the .htaccess file. I can double-encode the value as a workaround, but it seems that Apache should still process the mod_rewrite phases. I intend the URL merely to be an input parameter to the script.

Here are the (ir)relevant mod_rewrite directives in /myfolder/.htaccess:

RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule .* ./script-the-world.php

The rewrite rules are NOT being processed. In the server configuration I've got RewriteLogLevel 5, etc., and tail -f /var/log/http/rewrite.log shows all my requests to /myfolder/ being rewritten... except for the one mentioned above. I mean to say that something internal is happening in the special case above, but I have no clue what it is. I'm hoping someone might know of another module that is interfering with what I'm trying to accomplish.

This is Apache 2.2.16.

share|improve this question

migrated from stackoverflow.com Apr 20 '11 at 11:00

This question came from our site for professional and enthusiast programmers.

    
What does your rule look like? –  halfdan Apr 18 '11 at 16:32

1 Answer 1

up vote 2 down vote accepted

You'll need to enable AllowEncodedSlashes, which will cause Apache to allow URLs with %2F and %5C in them, instead of throwing a 404. You will still, of course, have to make sure that your php script is handling the decoding of the URL correctly, as that's not Apache's duty.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.