htaccess重定向301 https www到非www

时间:2016-12-18 20:45:22

标签: .htaccess redirect ssl web https

目前只有主页从www.example.com和example.com重定向到https://example.com

我尝试重定向:

1. http://www.example.com/otherpages to https://example.com/otherpages 
2. http://example.com/otherpages to https://example.com/otherpages
3. https://www.example.com to https://example.com
3. https://www.example.com/otherpages to https://example.com/otherpages

试图使用一些以前的问题,但无法弄清楚。

.htaccess中的当前状态是:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://my-domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.my\-domain\.com [NC]
RewriteRule ^(.*)$ http://my-domain/$1 [L,R=301]
</IfModule>

提前致谢

1 个答案:

答案 0 :(得分:3)

您根据需要的条件不需要所有代码。用此替换您的所有代码并更改为您的域。

mysql()
相关问题