简单的 url 重写

发布于 2024-10-02 20:20:32 字数 472 浏览 0 评论 0原文

如何添加到 .htaccess 文件,以便在 url 包含某个变量时以下规则不适用?

# Options All
# Options -Indexes
#
# RewriteEngine on
#
# RewriteCond %{HTTP_REFERER} !^$
# RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC]
# RewriteRule (.*)$ /shared/php/v1/hotmusiclink.php?p=$1 [L]

# AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI

例如,上面的内容应该将所有 url 重定向到 hotmusiclink.php,除非它们的 url 中有字符串 ?code=s0mec0de

谢谢:)

How can i add to a .htaccess file so that the following rules don't apply if the url contains a certain variable?

# Options All
# Options -Indexes
#
# RewriteEngine on
#
# RewriteCond %{HTTP_REFERER} !^$
# RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC]
# RewriteRule (.*)$ /shared/php/v1/hotmusiclink.php?p=$1 [L]

# AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI

e.g. the above should redirect all url's to hotmusiclink.php, unless they have the string ?code=s0mec0de in the url

thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

楠木可依 2024-10-09 20:20:32

您可以使用RewriteCond来使任何给定的重写不被应用。

RewriteCond %{QUERY_STRING} !code=s0mec0de
RewriteRule ^.*$ /hotmusiclink.php

一直玩到它起作用为止。

You can use RewriteCond to make any given rewrite not be applied.

RewriteCond %{QUERY_STRING} !code=s0mec0de
RewriteRule ^.*$ /hotmusiclink.php

Play with that until it works.

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