0
我使用mod_rewrite
我.htaccess
改变双目录结构为双GET
查询字符串,像这样:mod_rewrite的双目录
网址:http://domain.com/index.php?u=test&c=me
使用:http://domain.com/test/me/
后的mod_rewrite以下代码在我的.htaccess
文件中:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?u=$1&c=$2 [L]
这很好,但如果没有指定第二个目录(例如, http://domain.com/test/
)我想c
变量等于“所有”,例如:
http://domain.com/index.php?u=test&c=all
我怎样才能做到这一点? 谢谢,正则表达式看起来像克林贡诗歌给我。我已经尝试了上述代码的几个不同的变体,但没有成功。
P.S.奖励积分,如果你能添加一个尾部/
即使一个不键入URL框中,使http://domain.com/test/me
的处理一样http://domain.com/test/me/
和http://domain.com/test
被视为同http://domain.com/test/
完美,谢谢! – themerlinproject 2012-03-03 00:08:15
看起来我很快就说话了。出于某种原因,当我将两个重写代码放在那里时,它会破坏我的脚本。它开始抛出一个意外的错误。如果我删除第二个重写规则,它会通过罚款。思考? – themerlinproject 2012-03-03 00:12:57
“意外的<错误”?你能否详细说明一下? – Kisaro 2012-03-03 00:15:37