【发布时间】:2015-09-08 20:04:16
【问题描述】:
我想将 http 请求重定向到 https 节点。
我试过了,
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
请看下面几个测试结果,我执行了,
http://sample.mydomane.co/ 重定向到 https://sample.mydomane.co/
//按预期工作
http://sample.mydomane.co/api-docs/ 未重定向到 https://sample.mydomane.co/api-docs/
//没有按预期工作
编辑:这是我的.htaccess 文件
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
#Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(api-docs|docs)($|/) - [L] # HERE IS THE PROBLEM I THINK
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# redirect all http -> https
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
请告诉我如何实现或解决此问题。
【问题讨论】:
-
我编辑了问题以包含 .htaccess 文件。请注意评论“这是我认为的问题”。