禁用基于引荐来源网址的样式表
Disable stylesheet based on referrer
我不想让样式表(由我托管)加载到几个域上。
这是我正在尝试的方法,但不起作用:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://example1.com/ [NC]
RewriteRule \.css$ http://www.mywebsite.com/dummy.css [R,L]
RewriteCond %{HTTP_REFERER} ^http://example2.com/ [NC]
RewriteRule \.css$ http://www.mywebsite.com/dummy.css [R,L]
我怎样才能让它发挥作用?
css/.htaccess
Options +FollowSymLinks
RewriteEngine On
# Redirect requests to load.php
RewriteCond %{REQUEST_URI} .*\.css$ [NC]
RewriteRule .* load.php
css/load.php
$referrer = $_SERVER['HTTP_REFERER'];
if (strpos($referrer, 'allowedwebsite1.com') !== false or
strpos($referrer, 'allowedwebsite2.com') !== false ) {
header("Content-type: text/css", true);
$css = file_get_contents("style.css");
echo $css;
}
else {
header("Content-type: text/css", true);
echo ''; // empty stylesheet
}
我不想让样式表(由我托管)加载到几个域上。
这是我正在尝试的方法,但不起作用:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://example1.com/ [NC]
RewriteRule \.css$ http://www.mywebsite.com/dummy.css [R,L]
RewriteCond %{HTTP_REFERER} ^http://example2.com/ [NC]
RewriteRule \.css$ http://www.mywebsite.com/dummy.css [R,L]
我怎样才能让它发挥作用?
css/.htaccess
Options +FollowSymLinks
RewriteEngine On
# Redirect requests to load.php
RewriteCond %{REQUEST_URI} .*\.css$ [NC]
RewriteRule .* load.php
css/load.php
$referrer = $_SERVER['HTTP_REFERER'];
if (strpos($referrer, 'allowedwebsite1.com') !== false or
strpos($referrer, 'allowedwebsite2.com') !== false ) {
header("Content-type: text/css", true);
$css = file_get_contents("style.css");
echo $css;
}
else {
header("Content-type: text/css", true);
echo ''; // empty stylesheet
}