【问题标题】:Why are is my homepage not redirecting?为什么我的主页没有重定向?
【发布时间】:2013-10-10 00:53:08
【问题描述】:

阅读大量有关创建正确重定向的内容,但仍然存在问题。

将网站从一个域移动到另一个域。目录结构也发生了变化。子页面运行良好,但主页却不行。这是我正在使用的代码:

  RewriteEngine on

  //301 Redirect Old File

  RewriteRule oldsite.net newsite.com [R=301,L]
  RewriteRule ^p_gallery.* http://www.newsite.com/gallery [R=301,L]
  RewriteRule ^p_purchase.* http://www.shop.newsite.com [R=301,L]

谢谢!

【问题讨论】:

标签: .htaccess redirect http-status-code-301


【解决方案1】:

确保您已启用 mod_rewrite。

【讨论】:

    【解决方案2】:

    因为你的第一条规则是错误的:

    RewriteRule oldsite.net newsite.com [R=301,L]
    

    您只能匹配 RewriteRule 中的 REQUEST_URI。

    应该是这样的:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.net$ [NC]
    RewriteRule ^ http://newsite.com%{REQUEST_URI} [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 2021-06-23
      • 2020-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多