htaccess从url重定向到另一个url

时间:2011-06-09 12:37:31

标签: .htaccess mod-rewrite

我想重定向以下网址:

http://abc.com/colleges/first.php

http://abc.com/first.php

使用mod_rewrite.htaccess

我该怎么做?

3 个答案:

答案 0 :(得分:0)

使用301重定向 示例:重定向301 /old/old.htm http://www.you.com/new.htm

答案 1 :(得分:0)

在.htaccess中尝试此代码:

Options -MultiViews +FollowSymLinks
RewriteEngine On

RewriteRule ^[^/]+/(.*)$ /$1 [L]

答案 2 :(得分:0)

如果它只是first.php页面,那么:

RewriteEngine on
RewriteBase /
RewriteRule ^colleges/first.php$ /first.php

如果/colleges文件夹中的每个页面都需要重定向到根目录:

RewriteEngine on
RewriteBase /
RewriteRule ^colleges/(.*)$ /$1
相关问题