【发布时间】:2018-12-05 11:28:17
【问题描述】:
如果我输入http://example.com,它将变成http://www.example.com。
www 重定向有效,但 https 无效。
但它在我的文章 (home.php) 中有效,如果我输入 www.example.com/article/1/article-name,它将变成我想要的 https://www.example.com/article/1/article-name。
为什么它在 index.php 上不起作用?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule ^page/(.*) /index.php?pagina=$1
RewriteRule ^article/(.*) /home.php?id=$1
RewriteRule ^sitemap\.xml$ sitemap.php [L]
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
ErrorDocument 404 /404.php
AddCharset UTF-8 .htm
AddCharset UTF-8 .html
AddCharset UTF-8 .php
Options -MultiViews
options -indexes
【问题讨论】: