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

I have the following RewriteRule:

RewriteRule ^like/(.+)$ ask.php/$1

Which works just fine for requests like:

/like/someting+here/something+else

But for requests where one of the path parts contains an escaped slash (%2F), the server spits out a 404 Not Found error:

/like/one%2Ftwo+things/

Is there any way to fix this? I tried both [B] and [NE] flags (separate and together) but nothing worked.

Edit: I also tried:

RewriteRule ^like/ ask.php
# or
RewriteRule ^like/(.*) ask.php

So that it doesn't necessarily have to match the slash. It's still not working.

share|improve this question
    
Is there a directory path, using your example, called "/like/one/two+things/" where "two+things" is a subdirectory of "one" which is a subdriectory of "like"? If not, you can't have filenames (at least in Unix) with a slash in them and I'd be willing to bet that if Apache allows an escaped slash there's a potential security issue. –  Dennis Williamson May 17 '10 at 13:19
    
No, there's no such path. But I don't see why it matters, since it should be internally rewritten to ask.php/$1, so there's no security issue :/ –  Felix May 17 '10 at 13:33
add comment

2 Answers

up vote 4 down vote accepted

Apache directive helped me

AllowEncodedSlashes On  
share|improve this answer
add comment

I found the answer here here. To quote the relevant bits:

The naked "%2f" is allowed in a query string. but not in a URL. In order to be valid, it would have to be encoded as %252f, which I think you will find to work as you expect.

Because the URL is itself invalid, the server is rejecting it before any apache modules are invoked.

For more information, see RFC2396 - Uniform Resource Identifiers (URI): Generic Syntax.

share|improve this answer
add comment

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.