从codeigniter url中删除index.php

我是codeigniter的新手.我在localhost / path / learn_ci上安装了我的codeigniter.

我已经遵循了codeigniter wiki中给出的所有步骤.这是我的.htaccess文件.

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

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

我还根据需要更改了配置文件.但是当我试图访问时
    

我收到这个错误

“The requested URL /learn_ci/index.PHP/welcome was not found on this server”

我已经仔细检查了…… Apache中的mod_rewrite模块已启用.

RewriteBase解决方案也不起作用.难道我做错了什么??

解决方法:

正如其他人所说,请确保在apache配置或虚拟主机文件中将AllowOverride设置为All.
鉴于您已设置codeigniter的路径,您的htaccess应如下所示:

RewriteEngine On
RewriteBase /path/learn_ci

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$/path/learn_ci/index.PHP/$1 [L]

此外,请记住您使用的任何资产(img,css,js等)都使用base_url()函数或使用相对路径引用.项目的根目录是/ path / learn_ci.

我发现创建虚拟主机并在本地向主机文件添加条目更容易.这样可以更好地模仿现实生活.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...