Php 使用Apache2.4重写CodeIgniter mod_

Php 使用Apache2.4重写CodeIgniter mod_,php,apache,.htaccess,codeigniter,mod-rewrite,Php,Apache,.htaccess,Codeigniter,Mod Rewrite,我很难让mod_rewrite与CodeIgniter一起工作。我正在运行Apache2.4 我的网络根目录是/Users/Jason/Development/www 这是我当前在与主index.php文件位于同一目录中的.htaccess文件中的代码 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /myapp/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond

我很难让mod_rewrite与CodeIgniter一起工作。我正在运行Apache2.4

我的网络根目录是/Users/Jason/Development/www

这是我当前在与主index.php文件位于同一目录中的.htaccess文件中的代码

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /myapp/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

重新启动发动机
重写库/myapp/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
ErrorDocument 404/index.php
我做错了什么?我一直收到一个404页面,说在此服务器上找不到请求的URL。

选项-索引+FollowSymLinks
Options -Indexes +FollowSymLinks

RewriteEngine On
RewriteBase /

 # exclude any paths that are not codeigniter-app related
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/docs

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L]    
 </IfModule>    

# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>    
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
重新启动发动机 重写基/ #排除与codeigniter应用程序无关的任何路径 重写cond%{REQUEST_URI}^/服务器状态 重写cond%{REQUEST_URI}^/服务器信息 重写cond%{REQUEST_URI}^/文件 重写cond%{REQUEST_FILENAME}-F 重写cond%{REQUEST_FILENAME}-D 重写规则^(.*)$index.php/$1[L] #以下是在FastCGI下重写的内容 重写规则^(.*)$index.php?/$1[L]

基于sigmoid检查Web服务器日志文件您的应用程序是否位于
www/myapp
?是否启用了apache mod_重写模块?检查apache配置上的AllowOverride。这允许htaccess运行。要测试htaccess是否正常工作,请在其中键入错误的内容(例如:htaccess开头的abcdef)。如果您遇到500个错误,htaccess正在工作,如果错误仍然是404,我相信您应该找到AllowOverride来为您的DocumentRoot启用它。Mike,是的,它位于那里。谢谢!!这正是我所需要的。我一直在用CI应用程序在服务器上启用HTTP/2(以及fastcgi等)。我使用的是PHP7.3,但它似乎运行良好。谢谢