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.
精彩评论