我想将网站IP重定向到我的网站https
,并且我想将非www网址重定向到www
网址。我写了这两条规则,但它们是冲突的。这是我的嘲笑:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#Redirect ip to site
RewriteCond %{HTTP_HOST} ^xx\.xx\.xxx\.xxx$
RewriteRule ^(.*)$ https://www.domain.pk/$1 [L,R=301]
#Redirect non-www to www
RewriteCond %{HTTPS_HOST} !^www\.
RewriteRule ^(.*)$ https://www.domain.pk/$1 [R=301,L]
</IfModule>
# END WordPress
答案 0 :(得分:0)
您是否尝试过此配置?
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^xx\.xx\.xxx\.xxx$ [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.domain.pk/$1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]