使用 .htaccess 强制使用 SSL 时出现问题
我有以下 .htaccess 文件:
Order deny,allow
Deny from all
Allow from XX.XXX.XXX.XXX
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
应该是:
- 只允许从我的 IP 进行访问(数字更改为 X 以保护无辜者)
- 将不是特定文件的任何请求发送到 /index.php
- 对整个域强制使用 https
据我所知,它与之前的项目相同,诚然,该项目位于不同的托管提供商上,但这就像一个魅力。这次,它会显示一条消息:“Firefox 检测到服务器正在以永远不会完成的方式重定向对此地址的请求。”。
任何人都知道发生了什么事&请问我需要改变什么?
I have the following .htaccess file:
Order deny,allow
Deny from all
Allow from XX.XXX.XXX.XXX
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Which is supposed to:
- Only allow access from my IP (numbers changed to Xs to protect the innocent)
- Send any request which is not a specific file through to /index.php
- Force https for the entire domain
As far as I can see, it's identical to a previous project, which was admittedly on a different hosting provider, but that worked like a charm. This time it's resulting in a message saying "Firefox has detected that the server is redirecting the request for this address in a way that will never complete.".
Anybody know what's going on & what I need to change please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您的新托管提供商正在使用某种设置(例如反向代理)来阻止设置 HTTPS 变量。您也许可以使用其他内容(例如 SERVER_PORT,或者远程代理设置的标头,假设有)来确定请求是 HTTPS 还是 HTTP。
Perhaps your new hosting provider is using some sort of setup (like a reverse proxy) that's preventing the HTTPS variable from being set. You may be able to use something else (like SERVER_PORT, or perhaps a header set by the remote proxy, assuming there is one) to determine if the request is HTTPS or HTTP.