从codeigniter 2.1.3中删除index.php
在我打开这篇文章之前,我花了三天的时间试图弄明白这一点,但一点运气都没有,所以请帮我解决。谢谢~~~~ 好的,这就是我到目前为止所做的:从codeigniter 2.1.3中删除index.php,php,codeigniter,codeigniter-2,Php,Codeigniter,Codeigniter 2,在我打开这篇文章之前,我花了三天的时间试图弄明白这一点,但一点运气都没有,所以请帮我解决。谢谢~~~~ 好的,这就是我到目前为止所做的: 安装CI 2.1.3的新副本,不更改任何文件夹的名称 创建一个新的.htaccess文件到CI根目录,其中包含我在Google上找到的所有结构 将config['index_page']更改为空,例如config['index_page']='' 设置配置['uri\u协议']='REQUEST\u uri'或'QUERY\u STRING' 甚至每次我进行上
# I got 500 error if I uncommend this line: <IfModule mod_rewrite.c>
#http://ci.dev/index.php/welcome/index this is works fine only if the above line commend out
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/?$1 [L]
# I got 500 error if I uncommend this line: </IfModule>
主机文件
127.0.0.1 localhost
127.0.0.1 test.dev
127.0.0.1 ci.dev
#the following line also enabled
LoadModule rewrite_module modules/mod_rewrite.so in httpd.conf
...
# The following code I placed at the bottom of https.conf file
NameVirtualHost *
<VirtualHost *>
ServerName localhost
DocumentRoot "/Applications/MAMP/htdocs"
</VirtualHost>
<VirtualHost *>
ServerName ci.dev
DocumentRoot /Users/coda/Sites/ci
<Directory /Users/coda/Sites/ci>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName test.dev
DocumentRoot /Users/coda/Sites/test
</VirtualHost>
httpd.conf文件
127.0.0.1 localhost
127.0.0.1 test.dev
127.0.0.1 ci.dev
#the following line also enabled
LoadModule rewrite_module modules/mod_rewrite.so in httpd.conf
...
# The following code I placed at the bottom of https.conf file
NameVirtualHost *
<VirtualHost *>
ServerName localhost
DocumentRoot "/Applications/MAMP/htdocs"
</VirtualHost>
<VirtualHost *>
ServerName ci.dev
DocumentRoot /Users/coda/Sites/ci
<Directory /Users/coda/Sites/ci>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName test.dev
DocumentRoot /Users/coda/Sites/test
</VirtualHost>
然后,一切都会好起来~ 将.htaccess文件与index.php文件一起放在应用程序根目录中。(检查htaccess扩展是否正确,Bz htaccess.txt对我不起作用。) 并将以下规则添加到.htaccess文件中
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
然后在application/config/config.php文件中找到以下行
$config['index_page'] = 'index.php';
将变量设置为空,如下所示
$config['index_page'] = '';
就是这样,对我来说很有效
如果不起作用,请尝试用这些参数逐个替换以下变量(“自动”、“路径信息”、“查询字符串”、“请求URI”和“原始路径信息”)
$config['uri_protocol'] = 'AUTO';
将.htaccess文件与index.php文件一起放在应用程序根目录中。(检查htaccess扩展是否正确,Bz htaccess.txt对我不起作用。) 并将以下规则添加到.htaccess文件中
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
然后在application/config/config.php文件中找到以下行
$config['index_page'] = 'index.php';
将变量设置为空,如下所示
$config['index_page'] = '';
就是这样,对我来说很有效
如果不起作用,请尝试用这些参数逐个替换以下变量(“自动”、“路径信息”、“查询字符串”、“请求URI”和“原始路径信息”)
$config['uri_protocol'] = 'AUTO';
注:
htdocs是根文件夹
ci_intro是代码点火器的文件夹
如果我们有相同的案例,那么您的.htaccess应该是这样的
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
重新启动发动机
重写库/ci_简介/
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$/index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
请注意,RewriteBase/ci_intro/将ci_信息更改为codeigniter文件夹。
注:
htdocs是根文件夹
ci_intro是代码点火器的文件夹
如果我们有相同的案例,那么您的.htaccess应该是这样的
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
重新启动发动机
重写库/ci_简介/
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$/index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
请注意,RewriteBase/ci\u intro/将ci\u信息更改为您的codeigniter文件夹。尝试此.htaccess(将其放入项目目录的根目录中,即/chat here):
如果您在子目录中有项目,请将其放入RewriteBase
,否则请将其删除尝试此.htaccess(将其放入项目目录的根目录,即/chat here):
如果子目录中有项目,请将其放入“重写库”,否则请将其删除尝试:
重新启动引擎
RewriteCond%{REQUEST\u FILENAME}-f
RewriteCond%{REQUEST\u FILENAME}-d
RewriteRule.*/codeigniterNameFolder/index.php/$0[PT,L]
更改CodeIgniterName文件夹:)试试:
重新启动引擎
RewriteCond%{REQUEST\u FILENAME}-F