.htaccess rewriteCond 忽略您自己的域

发布于 2025-01-09 06:25:22 字数 352 浏览 1 评论 0原文

如果我在 .htaccess 中有这样的规则:

RewriteCond %{QUERY_STRING} ^URL\=(.+?)(-[0-9]+)?$
RewriteRule ^(.*)$ /index.php? [R=404,L]

我该如何更改它,以便忽略来自网站自己的域的 ?URL= 之后的任何内容?

例如,my-domain.com?URL=http://porn.site 会被重定向,但 my-domain.com?URL=https://my-domain.com/ some-page 被忽略。

If I have a rule in .htaccess like this:

RewriteCond %{QUERY_STRING} ^URL\=(.+?)(-[0-9]+)?$
RewriteRule ^(.*)$ /index.php? [R=404,L]

how would I change it so that ignores anything after ?URL= from the site's own domain?

For example, my-domain.com?URL=http://porn.site gets redirected, but my-domain.com?URL=https://my-domain.com/some-page is ignored.

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

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

发布评论

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

评论(1

音栖息无 2025-01-16 06:25:22

您可以使用:

RewriteCond %{QUERY_STRING} !^URL\=https?://my-domain.com [NC]
RewriteCond %{QUERY_STRING} ^URL\=(.+?)(-[0-9]+)?$
RewriteRule ^(.*)$ /index.php? [R=404,L]

You can use:

RewriteCond %{QUERY_STRING} !^URL\=https?://my-domain.com [NC]
RewriteCond %{QUERY_STRING} ^URL\=(.+?)(-[0-9]+)?$
RewriteRule ^(.*)$ /index.php? [R=404,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文