views:

42

answers:

1

I want to replace calls like this:

www.mysite.com/sub/file.php?param1=x&param2=http://www.someurl.com

with:

www.mysite.com/sub/param1/param2

Param 1 is an integer number Param 2 is a url

I wrote this rewrite rule in htaccess:

RewriteCond %{REQUEST_URI} \/sub\/
RewriteRule sub\/([0-9]+)\/(.*)$  sub\/file.php?param1=$2&param2=$1 [L] 

Unfortunately param2 (the URL) starts with http:/www.someurl.com instead of http://www.someurl.com (note the single slash).

Any idea what causes it? When I call the same file with same parameters in the format www.mysite.com/sub/file.php?param1=x&param2=http://www.someurl.com , param2 does appear OK so it must be something with the rewrite rule.

+2  A: 

You need to grab the value from THE_REQUEST:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /sub/[0-9]+/([^?\ ]+)
RewriteRule ^sub/([0-9]+)/  sub/file.php?param1=$1&param2=%1 [L]
Gumbo