mod-rewrite与查询 [英] mod rewrite with query
问题描述
可能重复:
查询字符串和放大器;mod-rewrite
我试图使用mod-rewrite,使链接prettier加www和走:
http://example.com/folder/page.html
来
http://example.com/index.php?page=page&folder=folder
我已经成功的这一基本版本顶层页面,这是不是在文件夹中,但我puzzeled如何将这一规则,并得到显现文件夹中。我也想查询字符串,以保持如此piwik分析环节的工作,如:
http://example.com/folder/page.html?piwik=something
进入:
http://example.com/index.php?page=page&folder=folder&piwik=something
任何帮助将是最AP preciated,这是我有这么远:
< IfModule mod_rewrite.c>
的RewriteCond%{} HTTPS!=上
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)$ [NC]
重写规则^ HTTP://%1%{REQUEST_URI} [R = 301,L]
重写规则^([^ /] *)\。HTML $ /index.php?page=$1 [L]
< / IfModule>
您想要的 QSA
标记的&害羞;文档的 ,例如$ C $低于C:
重写规则^ /([^ /] + /)?(。+ \。HTML)$ /index.php?folder=$1&page=$2 [QSA,L]
参考: 找到了这个网页 http://httpd.apache.org/docs/2.0/mod/ mod_rewrite.html 只要按下CTRL + F,搜索QSA(不讲话引号)
Possible Duplicate:
Query Strings & Mod ReWrite
I'm attempting to use mod rewrite to make links prettier without www and go from:
http://example.com/folder/page.html
to
http://example.com/index.php?page=page&folder=folder
I've managed a basic version of this for top layer pages which are not in folders but am puzzeled how to include this rule and get folder to appear. I would also like query strings to stay so piwik analytic links work, such as:
http://example.com/folder/page.html?piwik=something
goes to:
http://example.com/index.php?page=page&folder=folder&piwik=something
Any help would be most appreciated, this is what I've got so far:
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteRule ^([^/]*)\.html$ /index.php?page=$1 [L]
</IfModule>
You want the QSA
flagDocs, example code below:
RewriteRule ^/([^/]+/)?(.+\.html)$ /index.php?folder=$1&page=$2 [QSA,L]
Reference: Found this page http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html Just hit CTRL+F and search for "QSA" (without speech marks)
这篇关于mod-rewrite与查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!