如何为这些情况编写.htaccess mod_重写规则?

如何为这些情况编写.htaccess mod_重写规则?,.htaccess,mod-rewrite,url-rewriting,apache2,.htaccess,Mod Rewrite,Url Rewriting,Apache2,希望转发以下内容: localhost/bla/index.html -> localhost/index.php?s=bla/index.html localhost/blub.html -> localhost/index.php?s=blub.html localhost/blog.html?site=10 -> localhost/index.php?s=blog.html&site=10 localhost/folder -> localhost/ind

希望转发以下内容:

localhost/bla/index.html -> localhost/index.php?s=bla/index.html
localhost/blub.html -> localhost/index.php?s=blub.html
localhost/blog.html?site=10 -> localhost/index.php?s=blog.html&site=10
localhost/folder -> localhost/index.php?s=folder
但我只想做重定向。html和文件夹

RewriteCond %{REQUEST_URI} .html$ [OR]
RewriteCond -d
RewriteRule (.*) /index.php?s=$1 [L,QSA]

只有当uri以“.html”结尾或者是文件夹时,才会将整个uri重写为?s=查询字符串。QSA标志应确保将.html文件(?site=10)上的查询字符串也添加到新url中。

非常好。非常感谢。我怎样才能使它与.html和.php一起工作呢?如果我想使用.php和.html(localhost/bla.php->localhost/index.php?s=bla.phpchange
.html$
(html | php)$
的第一条规则中,我得到一个500服务器错误:/[Fri-Dec 17 10:50:54 2010][alert][client 127.0.1]C:/xampp/htdocs/.htaccess:RewriteCond:bad参数行'-d'