如何在 codeigniter 项目中删除 index.php
how to remove index.php in codeigniter project
mathwork 文件夹中的我的 codeigniter 项目
mathwork 是另一个文件夹 admin 中的文件夹,其中包含 codeigniter 文件
admin admin是文件夹有一个codeigniter文件库都有
mathwork
--admin
当我想尝试以
身份访问时
http://localhost/mathwork/admin/authorize/add
它显示错误 404
当我尝试访问时
http://localhost/mathwork/admin/index.php/authorize/add
它工作正常
如何删除 index.php 并将 url 设为
http://localhost/mathwork/admin/authorize/add
在与 index.php
相同的目录中创建一个名为 .htaccess
的文件(如果是 Apache),打开它并添加以下内容:
RewriteEngine on
RewriteCond !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
接下来打开 config.php
并将 $config['index_page'] = "index.php"
更改为 $config['index_page'] = ""
。
您的网址现在应该可以在地址栏中没有 index.php
的情况下使用。
我用 wamp 和 xampp 和 windows 10
这个 .htaccess 对我来说似乎工作正常
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
将 htaccess 放在应用程序文件夹的外面
- 你的项目
- 你的项目 > admin <-- 应用文件夹
- 你的项目 > 管理员 > .htaccess
- 你的项目 > 管理员 > index.php
you may need to change the system ../system
- 你的项目
- 您的项目 > 前端 <-- 应用程序文件夹
- 你的项目 > 系统
- 你的项目 > .htaccess
- 你的项目 > index.php
在 config.php
$config['base_url'] = 'http://localhost/yourproject/';
$config['index_page'] = "";
您可以获得更多.htaccess here
mathwork 文件夹中的我的 codeigniter 项目 mathwork 是另一个文件夹 admin 中的文件夹,其中包含 codeigniter 文件 admin admin是文件夹有一个codeigniter文件库都有
mathwork
--admin
当我想尝试以
身份访问时http://localhost/mathwork/admin/authorize/add
它显示错误 404
当我尝试访问时
http://localhost/mathwork/admin/index.php/authorize/add
它工作正常
如何删除 index.php 并将 url 设为
http://localhost/mathwork/admin/authorize/add
在与 index.php
相同的目录中创建一个名为 .htaccess
的文件(如果是 Apache),打开它并添加以下内容:
RewriteEngine on
RewriteCond !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
接下来打开 config.php
并将 $config['index_page'] = "index.php"
更改为 $config['index_page'] = ""
。
您的网址现在应该可以在地址栏中没有 index.php
的情况下使用。
我用 wamp 和 xampp 和 windows 10
这个 .htaccess 对我来说似乎工作正常
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
将 htaccess 放在应用程序文件夹的外面
- 你的项目
- 你的项目 > admin <-- 应用文件夹
- 你的项目 > 管理员 > .htaccess
- 你的项目 > 管理员 > index.php
you may need to change the system ../system
- 你的项目
- 您的项目 > 前端 <-- 应用程序文件夹
- 你的项目 > 系统
- 你的项目 > .htaccess
- 你的项目 > index.php
在 config.php
$config['base_url'] = 'http://localhost/yourproject/';
$config['index_page'] = "";
您可以获得更多.htaccess here