2017-09-07 10 views
0

同じVPSでホストされているfoo.com(メインドメイン)とbar.com(アドオンドメイン)の2つのドメインがあります。htaccess Redirect:メインドメインとアドオンドメインとの競合

フォルダ:

public-html/ (default folder for foo.com) 
├── foo/  (desired folder for foo.com) 
├── bar/  (default folder for bar.com) 

私はここに

よ両方のドメインのHTTPSおよびWWWを強制すると、サブフォルダのpublic_htmlの/ fooへの

をfoo.comの見えないリダイレクトをしたいです

RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?foo\.com [NC] RewriteCond %{HTTP_HOST} !^bar.com [NC] RewriteCond %{HTTPS} off RewriteRule^https://www.foo.com%{REQUEST_URI} [NE,R=301,L] RewriteRule ^((?!foo/).*)$ /foo/$1 [L] RewriteCond %{HTTP_HOST} ^(www\.)?bar.com$ RewriteCond %{HTTPS} off RewriteRule^https://www.bar.com%{REQUEST_URI} [NE,R=301,L] 
    最初のドメインfoo.comは正常に機能しますが、bar.comは機能しません。
  • bar.comはhttps://www.foo.comを指します。私が削除した場合内部500エラー

を返す理由

  • www.bar.comまたはhttp://www.bar.comまたはhttps://www.bar.com私にはわかりません次のルール、bar.com作品とfoo.comはもう動作しません:

    RewriteRule ^((?!foo/).*)$ /foo/$1 [L] 
    

    私は、このルールによって矛盾しているからbar.comを除外できますか?

  • 答えて

    0

    これは良い作品:

    RewriteCond %{HTTP_HOST} ^(www\.)?bar.com$ 
    RewriteCond %{HTTPS} off 
    RewriteRule^https://www.bar.com%{REQUEST_URI} [NC,R=301,L] 
    
    RewriteCond %{HTTP_HOST} ^(www\.)?foo.com$ 
    RewriteCond %{HTTPS} off 
    RewriteRule^https://www.foo.fr%{REQUEST_URI} [NC,R=301,L] 
    
    RewriteCond %{HTTP_HOST} ^(www\.)?foo\.com$ 
    RewriteRule !^foo/ /foo%{REQUEST_URI} [L] 
    
    関連する問題