【发布时间】:2017-02-01 09:44:38
【问题描述】:
是否可以使用 htaccess 重定向,来自
http://example.com/redirect.php?url=http%3A%2F%2Fanother.com%2Fsmiley.gif
到url参数,
http://another.com/smiley.gif
请指教。
【问题讨论】:
标签: .htaccess redirect mod-rewrite
是否可以使用 htaccess 重定向,来自
http://example.com/redirect.php?url=http%3A%2F%2Fanother.com%2Fsmiley.gif
到url参数,
http://another.com/smiley.gif
请指教。
【问题讨论】:
标签: .htaccess redirect mod-rewrite
你可以用这个:
RewriteEngine on
RewriteCond %{THE_REQUEST} /redirect\.php\?url=.+([^/]+\.gif)\s [NC]
RewriteRule ^ http://another.com/%1? [NE,L,R]
这会将 /redirect.php?url=foobar/foobar.gif 重定向到 http://another.com/foobar.gif。
【讨论】:
http://another.com/http%3A%2F%2Fanother.com%2Fsmiley.gif。我想要的是重定向到http://another.com/smiley.gif 或http://bnother.com/image.jpg