この PHP コードを .htaccess ルールに書き直すには?
$url = "$_SERVER[HTTP_HOST]";
if(strrpos($url, "m.cloudcms.co") === false){
header("HTTP/1.0 403 Forbidden");
echo '<h1>Forbidden Access</h1>';
echo '<p>You have reached this page in error.</p>';
exit;
}
これが私の.htaccessです:
deny from all
allow from m.cloudcms.co
# caching static files
<IfModule mod_headers.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|bmp|js|css|swf|woff|svg|ttf|otf|eot)(\.gz)?$">
Header unset Pragma
Header unset ETag
Header set Cache-Control "max-age=-1, no-store, no-cache, must-revalidate"
</FilesMatch>
</IfModule>
FileETag None
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault M-1
ExpiresByType text/html M-1
ExpiresByType image/gif M-1
ExpiresByType image/jpeg M-1
ExpiresByType image/png M-1
ExpiresByType text/css M-1
ExpiresByType text/javascript M-1
ExpiresByType application/javascript M-1
ExpiresByType application/x-javascript M-1
ExpiresByType text/xml M-1
ExpiresByType image/svg+xml M-1
ExpiresByType application/x-font-ttf M-1
ExpiresByType application/x-font-truetype M-1
ExpiresByType application/x-font-opentype M-1
ExpiresByType application/vnd.ms-fontobject M-1
ExpiresByType application/x-font-woff M-1
</IfModule>
# For servers that support output compression, you should pick up a bit of
# speed by un-commenting the following lines.
php_flag zlib.output_compression On
php_value zlib.output_compression_level 9
これは現在、cloudcms.co と m.cloudcms.co の両方に対して 403 Forbidden メッセージを実行しています。