我需要一个htaccess规则,将http://oursite.com或http://www.oursite.com等所有类型的页面重定向到httpS://WWW.oursite.com
<IfModule mod_rewrite.c>
ErrorDocument 404 /page-404.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^\s]+)\.php\s [NC]
RewriteRule .* %1.html [R=301,L]
# make sure .php file exists for the requested .html file
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)\.html$ $1.php [L,NC]
</IfModule>
提前致谢!
答案 0 :(得分:0)
简短而简单:
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</ifmodule>