Apache的htaccess文件出现500错误的原因
来源:互联网 发布:mac finder 编辑:程序博客网 时间:2024/06/05 07:15
Apache 我平时很少用到,今天测试环境下碰到个问题,老是500错误莫名其妙
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^m/(.*)$ m.php/$1 [L] RewriteRule ^(.*)$ index.php/$1 [L]
一开始这么些,感觉应该是正常的逻辑吧,m/ 开头的都到 m.php 去然后终止,其他为匹配到 m 的则去 index.php,结果发现直接500错误,崩溃怎么改都不行。
然后郁闷的查看日志发现提示貌似重写进入死循环了。。。很是奇怪,感觉应该是规则的正则范围有问题
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.
换了个新写法
RewriteCond %{REQUEST_URI} ^/m/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^m/(.*)$ m.php/$1 [L] RewriteCond %{REQUEST_URI} !^/m/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [L]
分成了两部分,增加个 URI 的匹配条件,明确分为两种条件,
即:
1. 以 /m/ 开头
2. 不是以 /m/ 开头的
这样明确正则范围终于ok了,
结论,貌似 Apache 的 RewriteRule 中的正则规则是不能存在一条包含另一条的情况,必须每个规则明确,否则就会出现死循环或者正则递归过大的情况导致500错误
附一个apache 规则转换到 nginx 的工具地址:
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
0 0
- Apache的htaccess文件出现500错误的原因
- apache .htaccess文件的语法
- 无聊的apache错误(.htaccess pcfg_openfile)
- 无聊的apache错误(.htaccess pcfg_openfile)
- Apache的.htaccess文件增加用户认证
- apache中.htaccess文件的功能写法
- apache中.htaccess文件的功能写法
- 让htaccess文件生效的apache配置
- apache 下的.htaccess文件详解
- 实用的Apache .htaccess文件配置
- Apache服务器中的.htaccess文件的配置
- .htaccess 不起作用的原因
- .htaccess 不起作用的原因
- Apache服务器的.htaccess
- apache .htaccess 的应用
- htaccess文件位置引起的403错误,所有虚拟主机出现故障
- apache开启.htaccess及.htaccess的使用方法
- apache开启.htaccess及.htaccess的使用方法
- 关于世界重定义的思考
- Hadoop2.0架构
- 局部特征匹配 Local Feature Matching
- 3种隐藏键盘的方法——iOS
- ios 调用系统提示音教程
- Apache的htaccess文件出现500错误的原因
- 简易在线html编辑器
- 解读2015之大数据篇:大数据的黄金时代
- GP数据库中时间函数例子
- Git 添加空文件夹的方法
- Unity 基础 XML文件解析
- 离散--第五章 函数
- Android Studio同步远程Git代码到本地
- hdoj 4614 Vases and Flowers 【线段树 + 二分】