我不想让样式表(托管在我身上)加载到几个域上。
这就是我正在尝试的,但不起作用:
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]
我怎样才能让它发挥作用?
答案 0 :(得分:0)
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
}