2017-02-01 63 views
0

是否有可能与htaccess的重定向,从htaccess的重定向到URL参数

http://example.com/redirect.php?url=http%3A%2F%2Fanother.com%2Fsmiley.gif 

到URL参数,

http://another.com/smiley.gif 

请指点。

回答

0

您可以使用此:

RewriteEngine on 

RewriteCond %{THE_REQUEST} /redirect\.php\?url=.+([^/]+\.gif)\s [NC] 
RewriteRule^http://another.com/%1? [NE,L,R] 

这将重定向/redirect.php?url=foobar/foobar.gifhttp://another.com/foobar.gif

+0

谢谢@starkeen。但是,实际上我的问题与此类似http://stackoverflow.com/questions/7246497/htaccess-query-string-urldecode。它还没有解决我的问题。 – kun

+0

@ kun你的意思是“它没有解决我的问题”?它是否将网址重定向到错误的目的地,或者它的问题到底是什么? – starkeen

+0

@starken参数“url =”包含url,而不是你的示例路径。它被编码,并且不仅another.com。所以,用你的脚本,它会重定向到'http:// another.com/http%3A%2F%2Fanother.com%2Fsmiley.gif'。我想要的是重定向到'http:// another.com/smiley.gif'或'http:// bnother.com/image.jpg' – kun