重定向使用基于引用的htaccess
我们只希望从特定网站的用户使用我们的服务。有没有一种方法,以重定向不是来自一个特定的引荐,我们选择的网站的所有流量,通过htaccess的?
We only want users from a specific website to use our services. Is there a way to redirect all traffic that does not come from a specific referrer, to a website of our choosing, via htaccess?
此外,这是对仅在第一页。所以,如果他们进入我们的网站,他们会浏览一个新的页面,他们的引荐新页面将显然是他们已经在网站上。
Also, this is for the first page only. So if they get to our site, they're going to browse a new page, and their referrer for the new page would apparently be the site they are already on.
感谢您!
尝试在你的文档根目录增加这个在htaccess文件:
Try adding this in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://the-ok-domain.com [NC]
RewriteRule ^/?first-page.html$ http://the-website-of-your-choosing.com/ [L,R]
您也可以做,所以你添加自己的域引用站点检查:
You could also make it so you add your own domain to the referer check:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://the-ok-domain.com [NC]
RewriteCond %{HTTP_REFERER} !^http://your-domain.com [NC]
RewriteRule ^ http://the-website-of-your-choosing.com/ [L,R]
然后就可以包括所有在检查你的页面。
Then you can include all of your pages in the check.
请注意查阅情况可以很容易地伪造和使用mod_rewrite在你的任何子目录将supercede本规则的任何htaccess文件(除非这些htaccess的文件具有 RewriteOptions inheret
选项)
Note that referers can be easily forged and any htaccess file using mod_rewrite in any of your subdirectories will supercede these rules (unless those htaccess files have the RewriteOptions inheret
option set)