【问题标题】:.htaccess rewrite rule to replace TLDt.htaccess 重写规则以替换 TLDt
【发布时间】:2018-03-06 07:15:39
【问题描述】:

我需要将带有此 TLD (.it) 的任何请求重定向到此 TLD (.com) 例如:

http://example.it?i=3

到这里:

http://example.com?i=3

我们如何使用 htaccess 做到这一点?

【问题讨论】:

    标签: php regex .htaccess url-redirection


    【解决方案1】:

    您可以在.ir 域的站点根目录.htaccess 中使用此规则:

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^(.+)\.ir$ [NC]
    RewriteRule ^ http://%1.com%{REQUEST_URI} [L,R=301,NE]
    

    【讨论】:

      【解决方案2】:
      RewriteEngine on
      RewriteCond %{HTTP_HOST} !^example\.com$
      RewriteRule ^ http://example.com%{REQUEST_URI} [L,R=301]
      

      一直尝试它的工作

      【讨论】:

      猜你喜欢
      • 2014-06-30
      • 2016-08-09
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多