如何强制www除了url

时间:2017-05-22 18:30:36

标签: .htaccess

使用代码强制https与www

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com [OR]
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

如何使用WWW和没有WWW

使下面的URL工作
https://example.com/license/get_license.php
https://example.com/license/verified_license.php

1 个答案:

答案 0 :(得分:0)

分辨率

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/license/get_license\.php$
RewriteCond %{REQUEST_URI} !^/license/verified_license\.php$
RewriteCond %{HTTP_HOST} !^www\.example\.com [OR]
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

致谢:托管Webfaction