【问题标题】:.htaccess RewriteRule for long URL is not working长 URL 的 .htaccess RewriteRule 不起作用
【发布时间】:2015-07-23 00:12:29
【问题描述】:

我是新手。所以我可能会犯一些愚蠢的错误。 在我的 .htaccess 中,我编写了如下的 RewriteRule:

RewriteRule ^contactus$ /contact.php [L,B]

如果我的网址是http://localhost/contactus,那么它工作正常。 如果我的网址是http://localhost/countryname/contactus,那么它也可以正常工作。 但是当 url 像 http://localhost/songs/Bob+Marley+%26+The+Wailers/One+Love/contactus 时,页面不会重定向

请帮忙。

【问题讨论】:

标签: php apache .htaccess mod-rewrite


【解决方案1】:

匹配开头的^ 符号意味着它应该从字符串的开头开始匹配。这意味着您的第二个 URL (http://localhost/countryname/contactus) 也不应该匹配。

如果要匹配所有以“contactus”结尾的网址,只需从开头删除^

RewriteRule contactus$ /contact.php [L,B]

【讨论】:

    猜你喜欢
    • 2012-12-10
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-22
    相关资源
    最近更新 更多