3

我搜索了很多关于 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]

但它不起作用。我怎样才能解决这个问题?

4

1 回答 1

6

使用它可能会有所帮助:

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

编辑:

试试这个 :)

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

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

于 2012-10-18T18:17:16.197 回答