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

Ant的神奇解决方案是:

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