第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > apache php 重写url无效 apache用rewrite重写url时出现问题

apache php 重写url无效 apache用rewrite重写url时出现问题

时间:2020-08-10 21:05:02

相关推荐

apache php 重写url无效 apache用rewrite重写url时出现问题

在用ThinkPHP框架做开发时,用apache的rewrite来隐藏url里入口文件index.php,在windows下一切正常,但是到了ubuntu下,其他的都正常,只有请求地址后边是index时会出现404 not found错误,比如访问localhost/tpapp/login,能够正常重写为localhost/tpapp/index.php/login,但是访问localhost/tpapp/index却会出现404错误

看了apache的错误日志,提示是这样的,Negotiation: discovered file(s) matching request:

/var/www/tptest/index (None could be negotiated).

,貌似是说找到多个可能的路径,无法决定是哪个?

.htaccess文件内容如下

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

从结果来看,重写规则没有执行,因为如果执行了到话会被路由到Xx模块下的index方法,而不是出现404 not found。

我的问题跟这位仁兄(/q/10100000001...)的是一样的,但是下边的解决方法不适合我..

求大神解答!弄了一下午了还没搞懂,虽然可以避免用index,但总觉得这里有点迷糊。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。