8

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.

2
  • 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. May 17, 2010 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, 2010 at 13:33

2 Answers 2

9

Apache directive helped me

AllowEncodedSlashes On  
7

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .