Mod Rewrite 变量包含带有特殊字符的 url
我最近发现了 mod 重写,我想知道是否可能 重写包含出站 url 的变量。
到目前为止它根本不起作用。我认为这是由于变量中的特殊字符引起的,我不知道如何解决这个问题。
到目前为止我的 .htaccess 代码:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^url/(\w+)/?$ link.php?url=$1 [L]
我想重写:
http://www.example-site.com/url/http://www.affiliate-site.com/dir/index.php?page=home
致:
http://www.example-site.com/link.php?url=http://www.affiliate-site.com/dir/index.php?page=home
任何帮助将不胜感激。
提前致谢。
I recently discovered mod rewrite and I was wondering if it's possible
to rewrite a variable which contains an outbound url.
So far it is not working at all. I assume it is caused because of the special characters in the variable and I have no clue how I can solve this.
My .htaccess code so far:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^url/(\w+)/?$ link.php?url=$1 [L]
I would like to rewrite:
http://www.example-site.com/url/http://www.affiliate-site.com/dir/index.php?page=home
To:
http://www.example-site.com/link.php?url=http://www.affiliate-site.com/dir/index.php?page=home
Any help would be much appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
\w
仅是 az、AZ 和 0-9这应该可以解决问题:
此备忘单可以提供帮助:
http://regexlib.com/CheatSheet.aspx
\w
is only a-z, A-Z and 0-9This should do the trick:
This cheat sheet can help:
http://regexlib.com/CheatSheet.aspx