开发者

How to write .htaccess mod_rewrite rules for these cases?

Want to forward开发者_StackOverflow the following:

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

but I only want do redirect .html and folders.


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

Only if the uri ends with ".html" or if it's a folder, it rewrites the entire uri into the ?s= query string. The QSA flag should make sure that query strings on .html files (?site=10) are added to the new url as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜