Apache 如何将/?blabla重写为其他url?
如何使用.htaccess重写Apache 如何将/?blabla重写为其他url?,apache,.htaccess,url-rewriting,Apache,.htaccess,Url Rewriting,如何使用.htaccess重写 ?p_action=user_profile to /user 它似乎忽略了“?”字符,我不知道该怎么办 谢谢 更多细节:(我的问题现在扩大了…:p) 我有www.example.com/?p\u action=user\u profile&post\u author=34 我希望浏览器显示www.example.com/nice\u url 当我在浏览器中输入“丑陋”或“美好”url时 也就是说,如果我输入www.example.com/nice\u url,
?p_action=user_profile to /user
它似乎忽略了“?”字符,我不知道该怎么办
谢谢
更多细节:(我的问题现在扩大了…:p)
我有www.example.com/?p\u action=user\u profile&post\u author=34
我希望浏览器显示www.example.com/nice\u url
当我在浏览器中输入“丑陋”或“美好”url时
也就是说,如果我输入www.example.com/nice\u url
,我希望发生url\u重写,
如果我输入www.example.com/?p\u action=user\u profile&post\u author=34,我希望它被重定向到www.example.com
问题是:我可以点头重写“?”标记,但我克服了它(幸运地)
下面是我的代码:
RewriteRule ^nice_url$ ?p_action=user_profile&post_author=34 [L]
RewriteCond %{QUERY_STRING} p_action=user_profile&post_author=34
RewriteRule (.*) http://www.example.co.il/nice_url? [R=301,L]
但是,这会创建一个循环
我试着加上这个
RewriteCond %{ENV:REDIRECT_STATUS} 200 #looks if there was a redirect
RewriteRule .* - [L]
但这没有帮助。我想这是因为我正在使用Wordpress,并且已经有一些重定向
请帮忙。如何使我的浏览器始终显示“www.example.com/nice_url”
谢谢 将重定向状态条件直接添加到规则中
RewriteRule ^nice_url$ ?p_action=user_profile&post_author=34 [L]
RewriteCond %{ENV:REDIRECT_STATUS} !=200
RewriteCond %{QUERY_STRING} p_action=user_profile&post_author=34
RewriteRule .* http://www.example.co.il/nice_url? [R=301,L]
这也可以防止弄乱其他WordPress规则。请提供更多信息。请看,我已经编辑了这个问题。谢谢