htaccess mod rewrite changes http://www to http:/www
I want to replace calls like this:
www.mysite.com/sub/file.php?param1=x¶m2=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¶m2=$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¶m2=http://www.someurl.com
, param2 does appear OK so it must be something with the rewrite rule.
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¶m2=%1 [L]
精彩评论