gpt4 book ai didi

php - 从 codeigniter url 中删除 index.php

转载 作者:可可西里 更新时间:2023-10-31 23:08:30 24 4
gpt4 key购买 nike

我是 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]

此外,请记住您正在使用的任何 Assets (img、css、js 等)都是通过 base_url() 函数或使用相对路径引用的。您的项目的根将是/path/learn_ci。

我发现创建一个虚拟主机并在本地向我的主机文件添加一个条目更容易。这更好地模拟了现实生活。

关于php - 从 codeigniter url 中删除 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10992462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com