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

.htaccess htaccess-重定向查询字符串并将其删除,.htaccess,redirect,.htaccess,Redirect,我搜索了很多关于htaccess的主题,但仍然没有成功 我想当人们键入地址时: http://domain.com/download.php?q=filename1 http://domain.com/download.php?q=filename2 它将自动重定向到: http://domain.com/download/filename1.html http://domain.com/download/filename2.html 如何修复此问题?尝试以下方法: RewriteEngin

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

我想当人们键入地址时:

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

http://domain.com/download/filename1.html
http://domain.com/download/filename2.html
如何修复此问题?

尝试以下方法:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^q=(.+)$ [NC]
RewriteRule ^download\.php download/%1.html? [R=301,L]