.htaccess htaccess-重定向查询字符串并将其从URL中删除

.htaccess htaccess-重定向查询字符串并将其从URL中删除,.htaccess,redirect,.htaccess,Redirect,我搜索了很多关于htaccess的主题,但仍然没有成功 我想当人们键入地址时: http://domain.com/?q=filename1 http://domain.com/?q=filename2 ... 它将自动重定向到: http://domain.com/download/filename1.html http://domain.com/download/filename2.html ... 我尝试: RewriteEngine On RewriteRule ^/?q=(.*)$

我搜索了很多关于htaccess的主题,但仍然没有成功

我想当人们键入地址时:

http://domain.com/?q=filename1
http://domain.com/?q=filename2
...
它将自动重定向到:

http://domain.com/download/filename1.html
http://domain.com/download/filename2.html
...
我尝试:

RewriteEngine On
RewriteRule ^/?q=(.*)$ /download/$1.html [L,R=301]

但它不起作用。如何解决此问题?

使用此选项可能会有所帮助:

RewriteEngine On
RewriteCond %{QUERY_STRING} q=(.*)
RewriteRule ^q(.*) /download/%1.html [L,R=301]
编辑:

试试这个:)


通过使用
查询字符串将被删除;)

谢谢Mehrnaz K.但它重定向到而不是existPlease fix,如果使用?q=filename1,则不会显示内容并显示:页面未正确重定向Firefox检测到服务器正在以一种永远无法完成的方式重定向对此地址的请求。此问题有时可能是由于禁用或拒绝接受Cookie造成的。您好,Mehrnaz K。新代码不起作用,它仍然(不重定向)。请help@LoveKen,对不起,这个新的很好用,请测试一下,谢谢
RewriteEngine On
RewriteCond %{QUERY_STRING} q=(.*)
RewriteRule ^(.*) /download/%1.html? [L,R=301]