The requested URL Not Found问题

时间:2023-03-08 21:58:12

遇到这么一个问题:

最近刚转到linux下工作

在本地运行localhost下的thinkphp程序时,出现

The requested URL Not Found问题

一开始以为是权限问题,把目录以及文件权限都改为777依然不起作用

后来发现是rewrite问题,解决步骤如下:

1.开启apache的rewrite模块

2.在配置文件apache2.conf将所有的AllowRewrite None都改为AllowRewrite All

3.在项目所在目录下,新建.htaccess文件,写入

  1. <IfModulemod_rewrite.c>
  2. RewriteEngine
    on
  3. RewriteCond
    %{REQUEST_FILENAME} !-d
  4. RewriteCond
    %{REQUEST_FILENAME} !-f
  5. RewriteRule
    ^(.*)$ index.php/$1 [QSA,PT,L]
  6. </IfModule>

4.重启apache,问题解决!