.htaccess重定向-更改文件名和查询字符串顺序

.htaccess重定向-更改文件名和查询字符串顺序,.htaccess,redirect,.htaccess,Redirect,我必须按如下方式重定向我的页面: 如果我有 mysite.com/abc.php?id=12345 mysite.com/abc.php?id=55626 我必须转到 mysite.com/def/12345.html mysite.com/def/55626.html 如果我有 mysite.com/abc.php?id=12345 mysite.com/abc.php?id=55626 我必须转到 mysite.com/def/12345.html mysite.com/def

我必须按如下方式重定向我的页面:

如果我有

mysite.com/abc.php?id=12345
mysite.com/abc.php?id=55626
我必须转到

mysite.com/def/12345.html
mysite.com/def/55626.html
如果我有

mysite.com/abc.php?id=12345
mysite.com/abc.php?id=55626
我必须转到

mysite.com/def/12345.html
mysite.com/def/55626.html
请告知

=====================================================

下面的代码解决了我的问题

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^abc\.php$ http://mysite.com/def/%1.html? [R=301,L] 

到目前为止,您尝试了什么,有什么问题吗?作为一个观众,使用
.php
向我表明,是php脚本驱动了这件事。那你为什么使用
.htaccess
而不是
header()
?我对重定向规则没有经验。abc.php和def都是.php文件。12345.html是查询字符串。我需要我的路径看起来像一个带有.html bu it still.php的静态页面file@lgal请回答我的问题。