【问题标题】:redirect 301 to in htaccess is not working [duplicate]将 301 重定向到 htaccess 中不起作用 [重复]
【发布时间】:2012-12-14 17:53:19
【问题描述】:

可能重复:
htaccess 301 redirect not working

当有人想要test.php to newpage.php时,我需要重定向。

我的 htaccess 包含:

Options All -Indexes
RewriteEngine on
RewriteRule ^contact.shtml$ contact.php [NC]

RewriteRule ^news/(.*)/(.*)$ news_main.php?id=$1&title=$2 [L]

Redirect /test.php http://mydomain.com/newpage.php

但它不起作用。这里有什么问题吗?如果是我们,请帮助我。

【问题讨论】:

标签: php .htaccess


【解决方案1】:

如果重定向很重要,则应将其放在与重写模块相关的部分上方。

此外,如果您想要 301(永久)重定向,则需要指定它。默认情况下,重定向是 302。

除此之外,一切都在我眼中。

# Core Module
Options All -Indexes

# Alias Module
Redirect 301 /test.php http://mydomain.com/newpage.php

# Rewrite Module
RewriteEngine on
RewriteRule ^contact.shtml$ contact.php [NC]
RewriteRule ^news/(.*)/(.*)$ news_main.php?id=$1&title=$2 [L]

【讨论】:

    【解决方案2】:

    您可以直接在.htaccess文件中添加如下代码-

    重定向 301 /test.php http://mydomain.com/newpage.php

    【讨论】:

      猜你喜欢
      • 2013-04-06
      • 2017-06-30
      • 2014-07-05
      • 2014-12-21
      • 2011-03-08
      • 2013-03-14
      • 2023-03-27
      相关资源
      最近更新 更多