0

我在 /dashboard/.htaccess [dashboard 实际上是一个文件夹] 中放置了这个重写规则:

RewriteRule ^([^/]*)$ index.php?mode=$1 [L]

我的结构是 index.php?mode=support,尽管 $_SERVER['QUERY_STRING'] 输出如下:

mode=index.php

Example: site.com/dashboard/index.php?mode=support should be site.com/dashboard/support

那么,我怎样才能让它解析参数值,而不是文件本身。

4

2 回答 2

1

在对正则表达式进行更多研究的同时设法解决了这个问题。

RewriteRule ^([a-z]+)$ index.php?mode=$1 [L,QSA]

Thi 解决了我的问题,首选加号而不是星号,因为它告诉引擎重复它零次或多次。(当我在 index.php 时,查询字符串根据需要为空)

于 2013-06-28T00:07:14.550 回答
0

Your rule is matching anything that starts with not a slash and doesnt contain a slash anywhere when your actual path is

/dashboard/support

to get the folder you actually want you need a base on there like this

RewriteBase /dashboard/

If that is placed above the rule, Then your redirect should be ok

于 2013-06-27T21:20:46.560 回答