apache Rewrite 规则 给url在特定开头的目录下增加指定的get参数 求指点

ImFantasy 2012-09-09 01:35:11


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(bj|gz|sh|sz)\/(.*)$ index.php/$2?city=$1 [QSA,PT,L]
RewriteRule ^(.*)$ index.php/$1?city=sz [QSA,PT,L]
</IfModule>




本来所有的请求是用最后一条规则重定向到index。php去。

现在要求,每个城市好像一个主目录一样。 比如:
baidu.com/house 默认访问的深圳 就是重定向到 baidu.com/index.php/house/index

baidu.com/bj/house 重定向到 baidu.com/index.php/house/index?city=bj

要防止bj被框架当做模块名称解析了. 上面那几条不行, 直接http500错误.

不知道有没有搞过类似需求的哥们 援助一下.


RewriteRule ^(bj|gz|sh|sz)\/(.*)$ index.php/$2?city=$1 [QSA,PT,L]
去掉这一行

就可以正常运行. 但是无法实现上面关于特定城市 目录的需求.


apache 错误日志


[Sun Sep 09 12:29:26.666902 2012] [core:error] [pid 27030] [client 192.168.1.150:2963] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://f5.domian.com/Detail/shenzheng-sese-hunshasheying_p-3196827167.html
...全文
237 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧