2016-03-09 16:22

3 tlds:强制只有一个+用htaccess删除www


I have 3 Domains pointing to the same hosting server, let's say:

Due to Ajax cross-domain issues & captcha, i wanted to force visitors to only access through while forcing removing www at the same time. I have a feeling that using htaccess is the best solution to achieve this.

So basically if calling in the browser any one of the following urls :,,,,

Should be redirected to

I couldn't find an answer to my exact case, so please be kind and bear with my limited knowledge.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • douxiluan6555 douxiluan6555 5年前

    You can use the following in htaccess :

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.net$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.example\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.org$
    RewriteRule ^(.*)$$1 [L,R,NE,NC]
    点赞 评论 复制链接分享
  • dongshanni1611 dongshanni1611 5年前

    A little improvement :

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.(net|org)+$ [OR]
    RewriteCond %{HTTP_HOST} ^$ 
    RewriteRule ^(.*)$$1 [L,R,NE,NC]
    点赞 评论 复制链接分享