mod_rewrite 重写规则中的域名
Domain name in mod_rewrite RewriteRule
任务是获取引用域并通过 RewriteRule 将其发送到我的脚本。我的决定是
SetEnvIf Referer "^https?://(.*)/" myref=
RewriteRule ^(.*)$ script.php?referer=%{ENV:myref}
它工作正常,但我想知道是否有任何方法可以做到这一点(也许使用 RewriteCond)?
mod_rewrite 有一个名为 %{HTTP_REFERER}
的变量。它包含你所期望的。你可以这样使用它:
RewriteCond %{REQUEST_URI} !^/script\.php$
RewriteRule ^ script.php?referer=%{HTTP_REFERER} [L]
有关详细信息,请参阅 the documentation。
任务是获取引用域并通过 RewriteRule 将其发送到我的脚本。我的决定是
SetEnvIf Referer "^https?://(.*)/" myref=
RewriteRule ^(.*)$ script.php?referer=%{ENV:myref}
它工作正常,但我想知道是否有任何方法可以做到这一点(也许使用 RewriteCond)?
mod_rewrite 有一个名为 %{HTTP_REFERER}
的变量。它包含你所期望的。你可以这样使用它:
RewriteCond %{REQUEST_URI} !^/script\.php$
RewriteRule ^ script.php?referer=%{HTTP_REFERER} [L]
有关详细信息,请参阅 the documentation。