htaccess将www重定向到非www不起作用

问题描述:

这在驱赶我香蕉。由于某些原因,我的域无法将https-WWW重定向到https-non-WWW。除了 https://www.nextoronto.com

This is driving me bananas. For some reason my domain will not work to redirect https-WWW to https-non-WWW. This works with every other permutation except https://www.nextoronto.com

我在.htaccess文件中使用什么代码可以使其适用于所有排列?

What code do I use in the .htaccess that will allow it to work for all permutations?

编辑:现在是重写代码:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.nextoronto\.com [NC]
RewriteRule ^(.*)$ https://nextoronto.com/$1 [L,R=301]


听起来不错,也许由于前面的其他规则未达到该规则?

It looks sound, perhaps that rule isn't being reached due to other rules in front of it?

这是我使用的有效的方法:

Here is what I use that works:

# 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...