Mod Rewrite 变量包含带有特殊字符的 url

发布于 2024-09-08 06:39:45 字数 534 浏览 1 评论 0原文

我最近发现了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日暮斜阳 2024-09-15 06:39:45

\w 仅是 az、AZ 和 0-9

这应该可以解决问题:

RewriteRule ^url/(.+)/?$ /link.php?url=$1 [L]

此备忘单可以提供帮助:
http://regexlib.com/CheatSheet.aspx

\w is only a-z, A-Z and 0-9

This should do the trick:

RewriteRule ^url/(.+)/?$ /link.php?url=$1 [L]

This cheat sheet can help:
http://regexlib.com/CheatSheet.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文