这让我发疯。出于某种原因,我的域无法将 https-WWW 重定向到 https-non-WWW。这适用于所有其他排列,除了 https://www.nextoronto.com
我在 .htaccess 中使用什么代码可以让它适用于所有排列?
编辑:这是现在重写的代码:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.nextoronto\.com [NC]
RewriteRule ^(.*)$ https://nextoronto.com/$1 [L,R=301]
最佳答案
看起来不错,也许由于它前面的其他规则而没有达到该规则?
这是我使用的有效方法:
# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://nextoronto.com/$1 [R=301,L]
# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://nextoronto.com/$1 [R=301,L]
# My other rewrites for routing all requests to index.php go here...
关于linux - htaccess 将 www 重定向到非 www 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36274893/