<分区>
我有这个 .htaccess 文件将所有请求重定向到根目录中的 index.php。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php
现在我想添加以强制将 http 协议(protocol)转换为 https。
我必须如何更改我的文件?
谢谢
最佳答案
如果您想强制所有对您域的请求都是安全的,请将下面的代码添加到您的 .htaccess 文件中。
RewriteEngine On
RewriteBase /
#if the request is not secure
RewriteCond %{HTTPS} off
#redirect to the secure version
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
#These are your existing rules
RewriteCond %{REQUEST_FILENAME} !.(jpg|jpeg|gif|png|css|js|pl|txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php
关于.htaccess 和 SSL 并重定向到 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8625213/
相关文章:
wordpress - 通配符 ssl .htaccess 文件在 laravel 子域上导致 500 错误
ruby-on-rails - 如何设置本地 SSL 证书和 Rails 应用程序?
ruby-on-rails-3 - 如何创建安全 Controller
html - 在您的根目录中有一个索引页面是否至关重要,例如 index.html、index.php
apache - htaccess 域 example.com 中的重定向错误 :443
java - 使用 Intellij 生成的代码、客户端证书和 session cookie 的 SOAP Webserice。独立工作。不适用于 glassfish 3.1.2.2