【发布时间】:2012-11-05 00:59:14
【问题描述】:
如何使用 mod_rewrite 实现这一点?
from:
.com/index.php?menu=home
to:
.com/home
与
from:
.com/index.php?menu=home&list=hello
to:
.com/home/hello
ALSO(没有文件夹 hierarki)
from:
.com/index.php?menu=home&list=hello
to:
.com/hello
我用这个做第一个:
RewriteRule ^([^/\.]+)/?$ index.php?menu=$1 [L]
但是如果有多个变量,我该如何连接它们呢?
试过这个:
RewriteRule ^([^/]*)/([^/]*)?$ index.php?home=$1&list=$2
【问题讨论】:
-
multiple variables是什么意思?如果您在谈论 GET 变量,则需要设置[L,QSA]它将所有 GET 参数传递给您的脚本。例如,如果用户转到.com/home/hello?testing=variable,它将把它传递给页面。这是你要求的吗? -
更新了我的问题。最后一行。
标签: php url mod-rewrite