.htaccess 如果子域不存在,则htaccess重写
我创建了一个子域用作无炊事域,它类似于cdn.domain.com 在主网站上我有www.domain.com。无论我叫它什么,它都是www.cdn.domain.com。我正在使用cdn.domain.com调用图像等 在这里您可以看到实际的htaccess设置.htaccess 如果子域不存在,则htaccess重写,.htaccess,.htaccess,我创建了一个子域用作无炊事域,它类似于cdn.domain.com 在主网站上我有www.domain.com。无论我叫它什么,它都是www.cdn.domain.com。我正在使用cdn.domain.com调用图像等 在这里您可以看到实际的htaccess设置 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] RewriteRule (.*?)i
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond $1 !^(index\.php|images|robots|public|sitemap.xml|favicon.ico|\.txt|\.html)
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
</IfModule>
重新启动发动机
RewriteCond%{THE_REQUEST}^GET.*index\.php[NC]
重写规则(.*)索引\.php/*(.*)/$1$2[R=301,NE,L]
#首先将任何请求重写到错误的域以使用正确的域(此处为www.)
重写cond%{HTTP_HOST}^www\。
重写规则^(.*)$https://www.%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
#现在,重写为HTTPS:
重写条件%{HTTPS}关闭
重写规则^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
1美元^(索引\.php | images | robots | public | sitemap.xml | favicon.ico | \.txt | \.html)
重写规则^(.*)$/index.php?/$1[L]
RewriteCond%{HTTP_USER_AGENT}libwww perl.*
重写规则。*?[F,L]
如何在不影响对主域设置的任何更改的情况下获取信息?我想您正在寻找以下信息:
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
您的htaccess现在看起来是这样的:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond $1 !^(index\.php|images|robots|public|sitemap.xml|favicon.ico|\.txt|\.html)
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
</IfModule>
重新启动发动机
RewriteCond%{THE_REQUEST}^GET.*index\.php[NC]
重写规则(.*)索引\.php/*(.*)/$1$2[R=301,NE,L]
#首先将任何请求重写到错误的域以使用正确的域(此处为www.)
重写条件%{HTTP\u HOST}^[^.]+\.[^.]+$
重写规则^(.*)$http://www.%{HTTP_HOST}/$1[L,R=301]
#现在,重写为HTTPS:
重写条件%{HTTPS}关闭
重写规则^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
1美元^(索引\.php | images | robots | public | sitemap.xml | favicon.ico | \.txt | \.html)
重写规则^(.*)$/index.php?/$1[L]
RewriteCond%{HTTP_USER_AGENT}libwww perl.*
重写规则。*?[F,L]
www添加到第二个块中,您应该添加另一个RewriteCond%{HTTP\u HOST}!cdn.domain.com
在那里。你可以在这里测试