【问题标题】:How do I redirect an .aspx url to a php page?如何将 .aspx url 重定向到 php 页面?
【发布时间】:2012-07-31 05:40:50
【问题描述】:

如何将 .aspx 网址重定向到 php 页面? 我有来自我的旧站点的链接 domain.com/song.aspx?SongID=1 我想重定向到 domain.com/song.php?SongID=2 文件。你能告诉我怎么做吗? 我愿意使用 htaccess 或插件。如果我使用插件,我需要能够让 song.php 也能在 song.aspx 之后获取查询字符串。

【问题讨论】:

    标签: redirect .htaccess


    【解决方案1】:

    Htaccess 可能是最好的方法。这条规则很笼统,但应该可以解决问题。

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

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

    【讨论】:

      【解决方案2】:

      如果您需要匹配查询字符串并更改 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]
      

      【讨论】:

        猜你喜欢
        • 2010-10-07
        • 2012-10-15
        • 2021-02-21
        • 1970-01-01
        • 2010-11-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多