Php 将301重定向到htaccess中的不工作

Php 将301重定向到htaccess中的不工作,php,.htaccess,Php,.htaccess,可能重复: 当有人想要test.php时,我需要重定向到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/newpa

可能重复:

当有人想要
test.php时,我需要重定向到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

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

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

此外,如果您想要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]

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


重定向301/test.php

我看不出您试图重定向到哪里。为什么您认为您的代码应该重定向?请仔细检查-并将其置于“重写引擎”部分上方。或的可能重复项