删除Codeigniter URL中的index.php

删除Codeigniter URL中的index.php,php,apache,.htaccess,codeigniter,mod-rewrite,Php,Apache,.htaccess,Codeigniter,Mod Rewrite,如何删除Codeigniter url中的index.php http://localhost/Sample/index.php 公正 http://localhost/Sample 我在互联网上搜索了一整天,什么也没找到。我正在使用Apache2.2,httpd.conf中的mod_重写已经启用。我使用的版本是Codeigniter 2.1.4 请一步一步地教我。我对Codeigniter框架还是很陌生。谢谢 您可以在.htaccess文件中使用以下代码: RewriteEngine On

如何删除Codeigniter url中的index.php

http://localhost/Sample/index.php
公正

http://localhost/Sample

我在互联网上搜索了一整天,什么也没找到。我正在使用Apache2.2,httpd.conf中的mod_重写已经启用。我使用的版本是Codeigniter 2.1.4


请一步一步地教我。我对Codeigniter框架还是很陌生。谢谢

您可以在.htaccess文件中使用以下代码:

RewriteEngine On
RewriteBase /my_project_name/
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

您可以在.htaccess文件中使用以下代码:

RewriteEngine On
RewriteBase /my_project_name/
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

您可以在.htaccess文件中使用以下代码:

RewriteEngine On
RewriteBase /my_project_name/
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

您可以在.htaccess文件中使用以下代码:

RewriteEngine On
RewriteBase /my_project_name/
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

您必须在两个地方进行此更改,一个是在
/application/config/config.php
中:

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
从索引页面中删除
index.php

第二位是(如上所述)更新/创建
.htaccess
文件,该文件与主
index.php
文件位于同一根文件夹中

请参阅CI指南:


所有内容都在指南中…

您必须在两个地方进行此更改,一个是在您的
/application/config/config.php
中:

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
从索引页面中删除
index.php

第二位是(如上所述)更新/创建
.htaccess
文件,该文件与主
index.php
文件位于同一根文件夹中

请参阅CI指南:


所有内容都在指南中…

您必须在两个地方进行此更改,一个是在您的
/application/config/config.php
中:

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
从索引页面中删除
index.php

第二位是(如上所述)更新/创建
.htaccess
文件,该文件与主
index.php
文件位于同一根文件夹中

请参阅CI指南:


所有内容都在指南中…

您必须在两个地方进行此更改,一个是在您的
/application/config/config.php
中:

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
从索引页面中删除
index.php

第二位是(如上所述)更新/创建
.htaccess
文件,该文件与主
index.php
文件位于同一根文件夹中

请参阅CI指南:


都在指南中…

在根文件夹中找到的.htaccess文件上尝试以下操作:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

在根文件夹中找到的.htaccess文件上尝试以下操作:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

在根文件夹中找到的.htaccess文件上尝试以下操作:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

在根文件夹中找到的.htaccess文件上尝试以下操作:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
您只需在项目文件夹中创建.htaccess文件并写入:
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#将所有其他URL重写为index.php/URL
重写规则^(.*)$index.php?url=$1[PT,L]
ErrorDocument 404 index.php
#您不需要在配置文件的base_url中定义:
$config['base_url']=''空白。
我希望它能完美地工作。。。
您只需在项目文件夹中创建.htaccess文件并写入:
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#将所有其他URL重写为index.php/URL
重写规则^(.*)$index.php?url=$1[PT,L]
ErrorDocument 404 index.php
#您不需要在配置文件的base_url中定义:
$config['base_url']=''空白。
我希望它能完美地工作。。。
您只需在项目文件夹中创建.htaccess文件并写入:
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#将所有其他URL重写为index.php/URL
重写规则^(.*)$index.php?url=$1[PT,L]
ErrorDocument 404 index.php
#您不需要在配置文件的base_url中定义:
$config['base_url']=''空白。
我希望它能完美地工作。。。
您只需在项目文件夹中创建.htaccess文件并写入:
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#将所有其他URL重写为index.php/URL
重写规则^(.*)$index.php?url=$1[PT,L]
ErrorDocument 404 index.php
#您不需要在配置文件的base_url中定义:
$config['base_url']=''空白。
我希望它能完美地工作。。。
首先在Apache服务器中启用“mod_rewrite”。 重新启动Apache服务器

将此代码添加到.htaccess(文件夹结构为Project\u Name/.htaccess)

首先在Apache服务器中启用“mod_rewrite”。 重新启动Apache服务器

将此代码添加到.htaccess(文件夹结构为Project\u Name/.htaccess)

首先在Apache服务器中启用“mod_rewrite”。 重新启动Apache服务器

将此代码添加到.htaccess(文件夹结构为Project\u Name/.htaccess)

首先在Apache服务器中启用“mod_rewrite”。 重新启动Apache服务器

将此代码添加到.htaccess(文件夹结构为Project\u Name/.htaccess)


我们需要先确认您已尝试解决方案。您能先给我们看一些示例代码吗?我们需要先看看您是否尝试了一个解决方案。您能先给我们看一些示例代码吗?我们需要先看看您是否尝试了一个解决方案。您能先给我们看一些示例代码吗?我们需要先看看您是否尝试了一个解决方案。你能先给我们看一些示例代码吗?