【问题标题】:Try to redirect full domain but home to a specific url尝试将整个域重定向到特定的 url
【发布时间】:2021-06-07 06:09:12
【问题描述】:

我正在尝试将域重定向到具有相同 url 的新域,但我需要主页(或“/”)转到特定的 url。

我用它来重定向所有具有相同结构的人

<IfModule https://mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^https://webantigua.com$ [OR]
 RewriteCond %{HTTP_HOST} ^https://www.webantigua.com$
 RewriteRule (.*)$ https://webnueva.com/$1 [R=301,L]
</IfModule>

但是我需要一个规则才能回家去https://webnueva.com/web-antigua/

我能做什么?

【问题讨论】:

  • 你能展示你的完整 .htaccess 吗?

标签: apache .htaccess redirect mod-rewrite url-rewriting


【解决方案1】:

您能否尝试遵循按照您显示的尝试编写的规则。 请确保在测试 URL 之前清除浏览器缓存。

<IfModule https://mod_rewrite.c>
 RewriteEngine ON
 ####OP's attempted rules here, with small fixes in them.
 RewriteCond HTTPS ON
 RewriteCond %{HTTP_HOST} ^(www\.)?webantigua\.com$ [NC]
 RewriteCond %{REQUEST_URI} !^/?$
 RewriteRule ^ https://webnueva.com%{REQUEST_URI} [NE,R=301,L]

 RewriteCond HTTPS ON
 RewriteCond %{HTTP_HOST} ^(www\.)?webantigua\.com$ [NC]
 RewriteRule ^/?$ https://webnueva.com/web-antigua/ [R=301,L]
</IfModule>

【讨论】:

  • 您好,感谢您的快速回答,但它不起作用。我清除所有缓存。最好的问候。
  • @Regue,你能不能给我看看不适合你的示例链接?
  • 主页 webantigua.com 未重定向到 webnueva.com/web-antigua
  • @Regue,是的,我的规则应该这样做,当你现在点击它时会发生什么?
  • 正常加载 webantigua.com 及其网址,不应用任何规则。不去 webnueva
猜你喜欢
  • 2021-09-07
  • 2018-02-15
  • 2017-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多