【问题标题】:Domain redirect .htaccess works only for subpages but not domain home域重定向 .htaccess 仅适用于子页面,但不适用于域主页
【发布时间】:2020-01-07 02:15:38
【问题描述】:

我正在尝试设置从 laundrylane.com.aulaundrylane.com

的简单重定向

这就是我所拥有的:

RewriteEngine On
RewriteRule ^(.*)$ https://laundrylane.com/$1 [R=301,L]

这适用于网站中的每个部分,例如:laundrylane.com.au/aboutus/ 转到 laundrylane.com/aboutus/

但如果我尝试自己访问域 laundrylane.com.au 它会将我重定向到 laundrylane.com/laundrylane.com.au/ 而不仅仅是索引,我尝试了多种规则和组合,但我无法让它工作,我想当 $1 是清空它会添加整个 URL

【问题讨论】:

  • 好的,因为它适用于部分但不适用于索引...我创建了一个带有 php 重定向的 Index.php,我不确定这是最佳实践,但它现在适用

标签: php .htaccess redirect mod-rewrite


【解决方案1】:

以下答案可能会导致新域的无限重定向...

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS_HOST} ^laundrylane\.com.au$ [NC]
RewriteRule ^(.*)$ https://laundrylane.com [R=301,L]

这对我有用

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2017-10-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-10
  • 1970-01-01
相关资源
最近更新 更多