2012-07-30 128 views
2

如何将.aspx url重定向到php页面? 我有我的旧网站的链接是domain.com/song.aspx?SongID=1,我想重定向到一个domain.com/song.php?SongID=2文件。你能告诉我如何做到这一点? 我打开要么使用htaccess或插件。如果我使用插件,我需要能够让song.php在song.aspx之后获得查询字符串。如何将.aspx url重定向到php页面?

回答

3

Htaccess可能是最好的选择。这条规则很普遍,但应该诀窍。

RewriteRule ^song\.aspx$ song.php [R=301,QSA,L] 

QSA代表“Query String Append”,并将查询字符串从旧URL附加到新URL。

0

如果您需要来匹配查询字符串,并更改ID就像在你的例子:

domain.com/song.aspx?SongID=1我想它重定向到domain.com /song.php?SongID=2

你需要设置为重写的列表:

RewriteCond %{QUERY_STRING} ^SongID=1$ 
RewriteRule ^/?song\.aspx$ /song.php?SongID=2 [R=301,L]