apache_conf HtAccess重写规则

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf HtAccess重写规则相关的知识,希望对你有一定的参考价值。

#redirect http non-www to https://www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?example\.co\.nz$
RewriteRule (.*) https://www.example.co.nz/$1 [R=301,L]

#redirect https non-www to www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^example\.co\.nz$
RewriteRule (.*) https://www.example.co.nz/$1 [R=301,L]


# force https for cname records with-out www redirect
RewriteCond %{HTTP_HOST} ^example\.co\.nz [NC]
RewriteRule ^(.*)$ https://www.example.co.nz/$1 [L,R=301,NC]

# force https for cname with-out www
RewriteCond %{HTTP_HOST} ^example.domain.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]


# redirect secondary domain to primary
RewriteCond %{HTTP_HOST} ^secondarydomain.co.nz [NC,OR]
RewriteCond %{HTTP_HOST} ^www.secondarydomain.co.nz [NC]
RewriteRule ^(.*)$ https://www.primarydomain.co.nz/$1 [L,R=301,NC

以上是关于apache_conf HtAccess重写规则的主要内容,如果未能解决你的问题,请参考以下文章

apache_conf HTTPS重写.htaccess

apache_conf 必须启用postname permalinksApache重写模块的基本.htaccess文件 - 主要用于YeoPress

apache_conf HTACCESS规则

apache_conf Joomla 3.x的htaccess规则

apache_conf 示例htaccess规则强制通过HTTPS的所有流量

apache_conf .htaccess缓存规则 - https://gist.github.com/kurtpayne/2920944