2017-05-11 15 views
1

ない場合、私はcdn.domain.comhtaccessの書き換えサブドメインが存在し

ように、私はwww.domain.comを持ってメインのサイト上にあるとしてcookilessドメインを使用するために作成したサブドメインを持っています。私が何を呼んでも、それはwww.cdn.domain.comとなります。私は、メインのドメイン設定に変更をせずにaffectting https://cdn.domain.comを得ることができますどのように

<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> 

設定実際のhtaccessファイルを見ることができるなどここで

画像を呼び出すためにcdn.domain.comを使用していますか?

+2

WWWは、あなたが他の 'するRewriteCond%{HTTP_HOSTを追加する必要があります第二のブロックに追加されます}!cdn.domain.com'があります。あなたはここでそれをテストすることができます[http://htaccess.mwl.be/](http://htaccess.mwl.be/) –

答えて

2

私はあなたがこのために探していると思う:

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> 
+1

downvotesを説明する気に? –