mod_rewrite rewrite_rule语法问题

发布于 2024-08-22 00:34:34 字数 554 浏览 2 评论 0原文

我的 .htaccess 当前有以下内容 -

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^go/([^/]*)/([0-9]+)/([0-9]+)/?$ http://foo.com/wp-content/plugins/foo/cloak.php?post_id=$2&link_num=$3&cloaked_url=$0 [L]
RewriteRule ^go/([^/]+)[/]?$ http://foo.com/wp-content/plugins/foo/cloak.php?name=$1&cloaked_url=$0 [L]
</IfModule>

我想更改它,以便域 'http://foo.com' 是自动检测并插入的(或者如果没有必要的话就省略。

我希望使用这个 .htaccess 来管理到同一代码库的多个映射域,并且不能真正让它与其中的特定 URI 一起工作。

I have the following in my .htaccess currently-

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^go/([^/]*)/([0-9]+)/([0-9]+)/?$ http://foo.com/wp-content/plugins/foo/cloak.php?post_id=$2&link_num=$3&cloaked_url=$0 [L]
RewriteRule ^go/([^/]+)[/]?$ http://foo.com/wp-content/plugins/foo/cloak.php?name=$1&cloaked_url=$0 [L]
</IfModule>

I want to change it so that the domain 'http://foo.com' is auto-detected and inserted (or just left off if it's unnecessary.

I'm hoping to use this .htaccess to manage multiple mapped domains to the same code base and can't really have it work with a specific URI in there.

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

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

发布评论

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

评论(1

顾北清歌寒 2024-08-29 00:34:34

使用 RewriteCond 来实现:

RewriteCond %{HTTP_HOST} !^foo.com$
RewriteRule ...

Use RewriteCond for that:

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