Mod_rewrite with "http://" in Querystring
I'm trying to create a rewrite rule that will do the following:
http://www.example.com/http://other.example.com
→ http开发者_StackOverflow社区://www.example.com/index.php?var=http://google.com
This is my current rule:
RewriteCond %{REQUEST_URI} ^/(http[s]?\:\/\/|ftp\:\/\/)?(www\.)?[a-zA-Z0-9-\.]+\.(com|org|net|mil|edu|ca|co.uk|com.au|gov|ws|info)$
RewriteRule ^(.*)$ http://www.example.com/index.php?var=$1 [R]
Which produces:
http://www.example.com/http://google.com
→
http://www.example.com/index.php?var=
http:/google.com
No matter what I try, I'm always getting http:/
out, instead of http://
. Any ideas?
Apache removes empty path segments like the one in http://
. So /foo//bar///
is interpreted like /foo/bar/
. But the original request line in THE_REQUEST
remains unchanged:
RewriteCond %{THE_REQUEST} ^GET\ /(https?://[^\ ]+)
RewriteRule ^https?:/ /index.php?var=%1 [R]
精彩评论