0

サイトがあり、次のリダイレクトが必要です。

1. http://mysite.net     => https://www.mysite.com
2. http://www.mysite.net => https://www.mysite.com
3. http://mysite.com     => https://www.mysite.com
4. http://www.mysite.com => https://www.mysite.com

1、2、3を達成しましたが、「リダイレクトが多すぎる」ため、4番目のもので問題が発生しています。これは私のhtaccessです:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
RewriteCond %{HTTP_HOST} ^(www.)?mysite\.net$
RewriteRule ^/?$ "https\:\/\/www\.mysite\.com\/" [R=301,L]

# Use PHP5.3 as default
AddHandler application/x-httpd-php53 .php

# Send all traffic of main domain to subdirectory

RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_URI} !^/sites/mysite.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sites/mysite.com/$1 [L]

RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ sites/mysite.com/index.php [L]

何か助けはありますか?

4

1 に答える 1

0

魔法の解決策は次のとおりです。

RewriteEngine on

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} ^(www.)?mysite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^(www.)?mysite\.net$
RewriteRule ^/?$ "https\:\/\/www\.mysite\.com\/" [R=301,L]

# Use PHP5.3 as default
AddHandler application/x-httpd-php53 .php

# Send all traffic of main domain to subdirectory

RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_URI} !^/sites/mysite.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sites/mysite.com/$1 [L]

RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ sites/mysite.com/index.php [L]
于 2012-07-26T23:12:19.537 に答える