首页 文章

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

提问于
浏览
5

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

  • 我在Apache中启用rewrite_module然后重启服务器

  • 我编辑了codeigniter文件夹中的.htaccess . 我根据文档中的示例添加了这个 .

RewriteEngine On

RewriteCond%! - f

RewriteCond%!-d

RewriteRule ^( . *)$ index.php / $ 1 [L]

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

  • 然后我创建一个简单的控制器:

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.

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

1 回答

  • 6

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

    使用wamp时确保已启用Apache Modules“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

    查找$ config ['index_page'] ='index.php';

    然后使index.php为空

    替换为$ config ['index_page'] ='';

    您可能需要配置路线

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

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

相关问题