我找到了这个问题的几个答案,但略有不同,有趣的是它对我不起作用。
我的目标是将任何 url 重写为 HTTPS 并删除 index.php
基本上我想要的是合并以下两个 htaccess 文件,但我对 htaccess 语法有些陌生:
RewriteEngine On
RewriteBase /
# If needed add 'www'
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
和
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
最佳答案
尝试这个 :
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
关于apache - .htaccess HTTPS 并删除 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34198999/