通过htaccess删除参数表单URL

时间:2014-04-22 07:28:04

标签: .htaccess mod-rewrite

我试图改变

http://localhost/archives?key=[uncicode string]

http://localhost/archives/[uncicode string]

例如

http://localhost/archives?key=سلdf

http://localhost/archives/سلdf

我该怎么做?

RewriteRule ^archives\/([.*]+)$ archives?key=$1

有什么问题?

1 个答案:

答案 0 :(得分:1)

尝试此规则:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+archives\?key=([^\s&]+) [NC]
RewriteRule ^ /archives/%1? [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^archives/([^/]+)/?$ /archives?key=$1 [L,B,NE,QSA]