我目前正在使用以下.htaccess,它会从所有网址http://littleloans.co.za/index.php的末尾删除.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ $1.php [L,QSA]
</IfModule>
我刚买了一张SSL证书,想要保留当前规则,但也要从http重定向到https
请为我解决任何问题?永久重定向
答案 0 :(得分:1)
只需在你的.htaccess中使用它:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
答案 1 :(得分:1)
添加此作为第一条规则应该有效。
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
答案 2 :(得分:1)
尝试:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
#redirect http to https and www to non-www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^ https://example.com%{REQUEST_URI} [NE,L,R=301]
#remove .php
RewriteCond %{SCRIPT_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L,QSA]
</IfModule>