301中的多Wordpress改写,但一个子域除外

时间:2019-03-22 20:18:19

标签: wordpress apache .htaccess redirect mod-rewrite

我读了另一篇类似的文章htaccess 301 redirect entire site but with exceptions,但它只为我提供了遵循的途径,没有真正的解决方法

我使用的是多关键字.htaccess,我有sub.domain.tdl之类的子域,而该子域不是www。我想在我的改写中为该域设置一个例外(见下文),

我尝试了RewriteCond %{HTTP_HOST} !^sub.domain.tdlRewriteCond %{HTTP_HOST} !=sub.domain.tdl

以下是我制定的规则摘要:

RewriteEngine On

# non-www to www (and HTTPS)
RewriteCond %{HTTP_HOST} !^sub.domain.tdl
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]

# HTTP to HTTPS 
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

谢谢

A。

0 个答案:

没有答案