【发布时间】:2018-02-14 11:26:01
【问题描述】:
我正在尝试使用 htaccess 和 mod_rewrite 将我网站的所有连接从 http 重定向到 https,我已经尝试了所有可能的方法但仍然无法正常工作,我收到如下错误:页面未正确重定向
htaccess 代码如下:
ErrorDocument 404 http://www.example.com/error.php
<IfModule mod_rewrite.c>
Options -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^([^/]*)\.html$ /index.php?lang=$1 [L]
RewriteRule ^sites/examplesite/([^/]*)\.html$ /index.php?lang=$1 [L]
RewriteRule ^([^/]*)/examplesite/([^/]*)\.html$ /index.php?lang=$1&page=$2 [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?lang=$1&page=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&idCat=$2&page=$3 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&cat=$2&filter=$3&pa=$4&page=$5 [L]
RewriteRule ^sites/examplesite/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&page=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&show=$2&page=$3 [L]
RewriteRule ^sites/examplesite/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&itemID=$2&idCat=$3&page=$4 [L]
RewriteRule ^sites/examplesite/([^/]*)//([^/]*)/([^/]*)\.html$ /index.php?lang=$1&idCat=$2&page=$3 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&idCat=$2&client_id=$3&page=$4 [L]
</IfModule>
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
php_flag display_errors On
【问题讨论】:
标签: .htaccess http redirect mod-rewrite https