Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite error in RegEx involving '/'

One slash followed by another is not rewritten properly

         

tarsus

3:16 pm on Aug 10, 2007 (gmt 0)

10+ Year Member



I'm trying to implement a rule that will accomplish the following:

Requested URL example:
[mysite.com...]

Rewritten URL:
[mysite.com...]

The idea is that the second slash after '200' is actually part of the file path to the image (and should be optional).

Here's my rule:

RewriteRule ^img_resize/(\d+)/(.+)$ scripts/img_resize.php?file=$2&size=$1 [L]

But for some reason, this rule rewrites the example above as if there were no second slash:

[mysite.com...]

What am I doing wrong?

tarsus

2:42 pm on Aug 13, 2007 (gmt 0)

10+ Year Member



This hasn't got everyone stumped, has it? ;)

Please let me know if there is any more information I can provide, or anything I need to clarify.

jdMorgan

3:46 pm on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because "//" has no defined meaning in URL/filesystem semantics, Apache treats it as a single slash -- notwithstanding the fact that search engines may not do the same.

If you wish that second slash to have some "meaning" in your system, I'm afraid you'll need to change your approach to use some other character.

Jim

tarsus

5:53 pm on Aug 14, 2007 (gmt 0)

10+ Year Member



Not worth the trouble. It should always be possible to provide a file path relative to the site root, so I'll simply stick with the single slash as part of the variable. Thanks for the info!