0

可能重复:
htaccess 301 重定向不起作用

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

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

4

2 回答 2

2

If the redirect is important, you should place it above the section that is related to the rewrite module.

Also if you want a 301 (Permanent) redirect, you need to specify it. By default, the redirect is 302.

Apart from that, everything looks right in my eyes.

# 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]
于 2012-12-14T09:33:41.047 回答
0

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

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

于 2012-12-14T09:34:59.027 回答