dongping6974 2016-03-09 16:22
浏览 24
已采纳

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

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

example.com 
example.net 
example.org

Due to Ajax cross-domain issues & captcha, i wanted to force visitors to only access through example.com 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 :

www.example.net, www.example.org, example.net, example.org, www.example.com

Should be redirected to example.com

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

Cheers,

  • 写回答

2条回答 默认 最新

  • douxiluan6555 2016-03-09 16:33
    关注

    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 ^(.*)$ http://example.com/$1 [L,R,NE,NC]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn