Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何防止静态域提供非静态内容?_.htaccess_Redirect_Static_Dns_Cookieless - Fatal编程技术网

.htaccess 如何防止静态域提供非静态内容?

.htaccess 如何防止静态域提供非静态内容?,.htaccess,redirect,static,dns,cookieless,.htaccess,Redirect,Static,Dns,Cookieless,我已经设置了一个静态域别名,以便在没有cookie的情况下提供静态内容,但是,由于这只是主域的别名,我担心如果无意中链接到它,那么它可能会被索引。我想通过在主站点.htaccess文件中设置条件来防止静态域别名提供CSS、JS、JPG、GIF文件等以外的任何服务 i、 e.类似于: 如果域名包含术语“static”,则将所有以.css、.js等结尾的文件“not”请求重定向到父域 有什么想法吗?在静态域的文档根中,将其添加到htaccess文件中(最好靠近顶部,或高于任何现有规则): Rewri

我已经设置了一个静态域别名,以便在没有cookie的情况下提供静态内容,但是,由于这只是主域的别名,我担心如果无意中链接到它,那么它可能会被索引。我想通过在主站点.htaccess文件中设置条件来防止静态域别名提供CSS、JS、JPG、GIF文件等以外的任何服务

i、 e.类似于:

如果域名包含术语“static”,则将所有以.css、.js等结尾的文件“not”请求重定向到父域


有什么想法吗?

在静态域的文档根中,将其添加到htaccess文件中(最好靠近顶部,或高于任何现有规则):

RewriteEngine On

# check if hostname includes "static"
RewriteCond %{HTTP_HOST} static

# and the request isn't for a file ending with one of these extensions
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gid|png)$ [NC]

# then redirect whatever the request is to the parent domain
RewriteRule ^(.*)$ http://parent.domain.com/$1 [L,R=301]