去掉codeigniter上的index.php/
我的去掉codeigniter上的index.php/,php,.htaccess,codeigniter,mod-rewrite,Php,.htaccess,Codeigniter,Mod Rewrite,我的.htaccess文件中有这个 <IfModule mod_rewrite.c> Options +FollowSymLinks Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.+$ /index.php [L]
.htaccess
文件中有这个
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.+$ /index.php [L]
</IfModule>
选项+FollowSymLinks
选项-多视图
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^.+$/index.php[L]
我的网站显示了我所有网站文件的index.php
内的文件。我试图摆脱必须输入mysite/index.php/filename
并直接进入mysite/filename
我的网址是http://local-news.today/subscribe
。当我使用这个地址localnews.today/index.php/subscribe
时,它可以工作,它显示了subscribe函数中的内容
我的网站位于戈达迪。我也在使用codeigniter。任何帮助都将不胜感激。我已在htaccess文件中完成以下操作:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
这对我很有用。我在htaccess文件中完成了以下操作:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
这对我很有用。将以下代码放入.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|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"
并将其替换为以下代码
$config['index_page'] = ""
将以下代码放入.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|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"
并将其替换为以下代码
$config['index_page'] = ""
对“codeigniter mod_rewrite htaccess”的简单搜索显示:
这是什么意思?
^(.*)$
从开始(^
)到结束($
)处理所有内容((.*)
),并使用$1
将其附加到index.php/
在您的示例中,您忘记将其附加到url的末尾…对“codeigniter mod_rewrite htaccess”的简单搜索显示:
这是什么意思?
^(.*)$
从开始(^
)到结束($
)处理所有内容((.*)
),并使用$1
将其附加到index.php/
在您的示例中,您忘了将其附加到url的末尾…根据我的经验,在共享主机上,您通常需要处理
.htaccess
文件。这一个通常对我有用:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt|static) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/?$1 [L,QSA]
但是您会注意到,这里的最后一行与其他答案不同,
?
位于/
之后,而不是在它之前(或者根本不在它之前)。因此,请尝试将其作为基本.htaccess
,然后根据需要修改最后一行。还可能需要删除RewriteBase\
行。根据我的经验,在共享主机上,您通常需要处理.htaccess
文件。这一个通常对我有用:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt|static) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/?$1 [L,QSA]
但是您会注意到,这里的最后一行与其他答案不同,
?
位于/
之后,而不是在它之前(或者根本不在它之前)。因此,请尝试将其作为基本.htaccess
,然后根据需要修改最后一行。可能还需要删除RewriteBase\
行。我总是使用这一行,它就像一个符咒:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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
#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.
ErrorDocument 404 /index.php
</IfModule>
重新启动发动机
重写基/
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#将“应用程序”重命名为应用程序文件夹名称。
重写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,一切正常。
ErrorDocument 404/index.php
我总是用这个,它就像一个符咒:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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
#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.
ErrorDocument 404 /index.php
</IfModule>
重新启动发动机
重写基/
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#将“应用程序”重命名为应用程序文件夹名称。
重写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,一切正常。
ErrorDocument 404/index.php
确保您在config.php
中有$config['index\u page']=''
。是的,我的已设置为该值。确保您在config.php
中有$config['index\u page']='
。是的,我的已设置为该值。local-news.today/subscribe/给我“未指定输入文件”。空白页。当我试图编一些无效的目录时,会得到相同的结果。您能解释一下这个问题吗?local-news.today/subscribe/给我“未指定输入文件”。空白页。当我试图编一些无效的目录时,会得到同样的结果。你能解释一下这个问题吗?