相关疑难解决方法(0)

CodeIgniter从url中删除index.php

我目前的网址看起来像这样[mysite]index.php/[rest of the slug].
我想index.php从这些网址中删除.

mod_rewrite在我的apache2服务器上启用.在config,$config['index_page'] = '';

我的codeignitor根.htaccess文件包含,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Run Code Online (Sandbox Code Playgroud)

但它仍然无法正常工作.我哪里错了?

php .htaccess codeigniter apache2

147
推荐指数
11
解决办法
34万
查看次数

Codeigniter - 如何从url中删除index.php?

我有以下项目结构

/system
/applications
  /cache
  /core
  /helpers
  /hook
  /language
  /libraries
  /logs
  /third_party
  /admin-panel
     /config
     /controllers
        welcome.php
        dashboard.php
     /errors
     /models
     /views
        welcome.php
        dashboard.php
  /user-panel
     /config
     /controllers
            welcome.php
            dashboard.php
     /errors
     /models
     /views
        welcome.php
        dashboard.php
/admin
  index.php
index.php
Run Code Online (Sandbox Code Playgroud)

我的项目文件夹中的index.php将user-panel作为我的应用程序文件夹,admin文件夹中的index.php将admin-panel作为我的应用程序文件夹.

我插入了这行$ route ['default_controller'] ="welcome"; $ route ['welcome'] ='welcome'; 在users.php中,在user-panel和admin-panel中

我可以通过使用访问我的用户面板和管理面板的欢迎控制器 http://localhost/myproject and http://localhost/myproject/admin

但我无法通过使用访问我的仪表板控制器 http://localhost/myproject/dashboard or http://localhost/myproject/admin/dashboard

我的仪表板控制器可以使用 http://localhost/myproject/index.php/dashboard or http://localhost/myproject/admin/index.php/dashboard

但我不希望index.php包含在我的网址中.我想删除它.我也试过在我的管理文件夹中使用.htaccess.我在这里写下面的一行

RewriteEngine On
RewriteCond $1 !^(index\.php|(.*)\.swf|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)

但这对我不起作用.它给出了404未找到的CI错误.我还通过在httpd.conf中将AllowOerride None更改为AllowOverride All来启用mod_rewrite.请告诉我如何删除index.php以及我应该将.htaccess文件放在项目目录中的哪个位置.

php codeigniter

6
推荐指数
2
解决办法
7884
查看次数

标签 统计

codeigniter ×2

php ×2

.htaccess ×1

apache2 ×1