保持主页重定向,但在整个网站上将http更改为https(包括子域名)

时间:2013-10-08 05:26:18

标签: php apache .htaccess redirect ssl

我检查了其他htaccess问题和答案,但似乎没有任何东西适用于这种情况。

以下代码是我当前的htaccess文件。有一个主页的重定向到位,我需要保留。我有网站的SSL密钥和证书,我只需要将http更改为https。

我确信这并不复杂,这只是出于我目前的知识。

请帮忙!

RewriteEngine on
RewriteCond $1 !^(index\.php|admin|gadgets|images|editor|user_guide|captcha|system|css|utils|src|themes|tools|xinha|uploads|js|robots\.txt)
RewriteRule ^(.*).html /$1 [L]

RewriteCond %{HTTP_HOST} ^startuptoolshop\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.startuptoolshop\.com$
RewriteRule ^/?$ "http\:\/\/startuptoolshop\.com\/index\.php\/categories" [R=301,L]

2 个答案:

答案 0 :(得分:0)

RewriteEngine on

下方插入此规则
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

答案 1 :(得分:0)

将此代码放在.htaccess文件中:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}