.htaccess 在htaccess中重写动态URL无效

.htaccess 在htaccess中重写动态URL无效,.htaccess,url,dynamic,rewrite,.htaccess,Url,Dynamic,Rewrite,我想重写 mypage.com/country/country.php?country=something 到 在地址栏中,使用htaccess 我尝试了很多东西,到处都找遍了,最接近的是: RewriteCond %{QUERY_STRING} country=([^\&]*) RewriteRule ^country.php$ /country/%1? [R,L] 但这只会产生一个重写循环,在上面的两个链接之间交替,我不明白为什么 我两者都要 my

我想重写

    mypage.com/country/country.php?country=something

在地址栏中,使用htaccess

我尝试了很多东西,到处都找遍了,最接近的是:

    RewriteCond %{QUERY_STRING} country=([^\&]*)
    RewriteRule ^country.php$ /country/%1? [R,L]
但这只会产生一个重写循环,在上面的两个链接之间交替,我不明白为什么

我两者都要

    mypage.com/country.php?country=something

输入时,显示

    mypage.com/country/something 
在地址栏中


有什么帮助吗?

如果你有一个重写循环,它表明除了这个规则之外,你还有一个将它翻译回来的规则。只有当“丑陋”url是外部请求时,才需要触发它。最简单的方法是匹配%{The_REQUEST}


真管用!非常感谢你。你不知道这有多令人沮丧。我现在只需要使我的相对样式表链接和图像成为绝对的,因为重命名改变了它们的路径,并导致页面生成时没有它们。使用。
    mypage.com/country/something
    mypage.com/country/something 
#Ugly to fancy url; should be R=301 when it works
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /country\.php\?country=([^\&]*)\ HTTP
RewriteRule ^country.php$ /country/%2? [R,L]

RewriteRule ^country/(.*)/?$ /country.php?country=$1 [L]