我正在尝试使用Bluehost提供的SSL通配符证书将一个子域切换到HTTPS。
web根目录包含许多子域,我只想影响测试。子域。
进入web根目录,我编写了以下.htaccess文件:
RewriteCond %{SERVER_NAME} ^test.mydomain.com
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}$1然而,点击http://test.mydomain.com/admin/index.php并不会将我重定向到https://test.mydomain.com/admin/index.php。
即使去掉了SERVER_NAME的条件,它仍然不能工作。
我的重写规则不好吗?
发布于 2013-05-15 04:39:41
首先,我在错误的.htaccess文件中。我需要进入我的子域的目录。
然后,简单地将它从HTTP切换到HTTP显然会导致某种重定向到www。行为。
我不得不
A)保留不打算用于测试的现有规则。B)添加测试。规则。
它加起来有很多。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^test.example.com$
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} !^test.example.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^test.example.com$
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^test.example.com$
RewriteCond %{REQUEST_URI} !^/test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /test%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^test.example.com$
RewriteRule ^(/)?$ test/admin/index.php [L]https://stackoverflow.com/questions/16552129
复制相似问题