【问题标题】:.htaccess redirect http:/www.domain.com/songs.php?movie=journey to http:/www.domain.com/songs.htaccess 将 http:/www.domain.com/songs.php?movie=journey 重定向到 http:/www.domain.com/songs
【发布时间】:2012-02-21 19:22:26
【问题描述】:

请帮忙!

需要从 http:/www.domain.com/songs.php?movie=journey 重定向到 http:/www.domain.com/songs

我需要删除查询字符串 (?movie=journey)。我不再想要它们了。

我试过了

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{Query_STRING} ^movie=journey$
RewriteRule ^(.*)$ /songs/$1 [R,L]

但在浏览器中显示如下 http://www.domain.com/songs/songs.php?movie=journey

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect


    【解决方案1】:

    在最后一条规则的末尾添加?

    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{Query_STRING} ^movie=journey$
    RewriteRule ^songs.php(.*)$ /songs/$1? [R,L]
    

    【讨论】:

    • domain.com/songs/songs.php 以这种方式在浏览器中显示的 url。但我不希望 url 中的songs.php。我希望网址为domain.com/songs
    • 又是一个问题。我在 RewriteCond %{Query_STRING} ^movie=([a-zA-Z0-9% ]*)$ RewriteRule ^(.*)$ /songs/? [R,L] 如果它像songs.php?movie=Racha%20Title%20Song 或songs.php?movie=Racha Title Song 它没有重定向你能告诉我这个plz的正则表达式吗?
    猜你喜欢
    • 1970-01-01
    • 2016-02-20
    • 1970-01-01
    • 2015-12-26
    • 1970-01-01
    • 1970-01-01
    • 2013-01-09
    • 1970-01-01
    • 2016-11-12
    相关资源
    最近更新 更多