gpt4 book ai didi

php - 无法使用 Codeigniter URL 删除 WAMP 中的 index.php

转载 作者:可可西里 更新时间:2023-11-01 14:01:20 24 4
gpt4 key购买 nike

我想删除 URL 中的 index.php,但它不起作用。这是我所做的:

  1. 我在我的 Apache 中启用了 rewrite_module,然后重新启动服务器
  2. 我在我的 codeigniter 文件夹中编辑 .htaccess。我根据文档中的示例添加了它。

    重写引擎开启

    重写条件 %{REQUEST_FILENAME} !-f

    重写条件 %{REQUEST_FILENAME} !-d

    重写规则 ^(.*)$index.php/$1 [L]

  3. 然后我也删除了app/config中的index.php

  4. 然后我创建一个简单的 Controller :

    class Users extends CI_Controller {

    public function __construct() {
    parent::__construct();
    }

    public function index() {
    echo "hello world";
    }

    }

当我访问这个 URL 时:

http://localhost/order_menu/users

我遇到了这个错误:

Not Found

The requested URL /order_menu/users was not found on this server.

你能帮我解决这个问题吗?

最佳答案

在 wamp apache 服务器上删除 codeigniter 中的 index.php!

当您使用 wamp 时,请确保您已启用 Apache 模块“rewrite_module”重新启动服务器

第二

在项目的主目录中试试这个 htaccess

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

然后去application/config/config.php

Find $config['index_page'] = 'index.php';

然后让index.php为空

Replace With $config['index_page'] = '';

您可能需要配置您的路线

CI3:http://www.codeigniter.com/user_guide/general/routing.html

CI2:http://www.codeigniter.com/userguide2/general/routing.html

关于php - 无法使用 Codeigniter URL 删除 WAMP 中的 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32576206/

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