在mod_rewrite的重写规则的域名 [英] Domain name in mod_rewrite RewriteRule

查看:108
本文介绍了在mod_rewrite的重写规则的域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的任务是获取引用者域和重写规则将其发送给我的剧本。我的决定是

The task is to get referer domain and send it to my script by RewriteRule. My decision is

SetEnvIf Referer "^https?://(.*)/" myref=$1
RewriteRule ^(.*)$ script.php?referer=%{ENV:myref}

它的工作原理正确的,但我不知道是否有什么办法做到这一点(可能的RewriteCond)?

It works right but I wonder if there are any ways to do it (perhaps with RewriteCond)?

推荐答案

的mod_rewrite中有一个名为变量%{HTTP_REFERER} 。它包含了你所期望的。您可以使用它是这样的:

mod_rewrite has a variable named %{HTTP_REFERER}. It contains what you expect. You can use it like this:

RewriteCond %{REQUEST_URI} !^/script\.php$
RewriteRule ^ script.php?referer=%{HTTP_REFERER} [L]

请参阅更多信息,文档

这篇关于在mod_rewrite的重写规则的域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆