我在使用Codeigniter2时遇到了一些麻烦。 基本上我想,这样从我的网址去掉恼人的“的index.php”:在Codeigniter 2中删除index.php
- http://localhost/ci_intro/index.php/site/home
Becomes
- http://localhost/ci_intro/home
我跟着一对夫妇已经在堆栈溢出的链接,并已发现以下两个职位:
Remove index.php From URL - Codeigniter 2
而且
Removing index.php from codeigniter-2
执行后,但是能够对S teps依然没有喜乐。
我的.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 ^(.*)$ /ci_intro/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 ^(.*)$ /ci_intro/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 ^(.*)$ /ci_intro/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>
我保证mod_rewrite的模块是在Apache中启用(我使用的XAMPP在Windows上),但由于某种原因,它只是不工作,我” d期待它。
我在CodeIgniter2中有两个视图,一个叫做Home,另一个叫About。这两个链接彼此。链接如下:
<a href="home">Home</a><br/>
<a href="about">About</a>
如果我去我的项目的根URL:
http://localhost/ci_intro/
主页的索引功能显示。这很好,和预期的一样。但是,如果我再单击链接重定向到:
http://localhost/ci_intro/home
or
http://localhost/ci_intro/about
其产生的404。但是,如果我再在网址栏中输入“地盘”,我的控制器的名称,链接带我穿越到正确加载的观点:
http://localhost/ci_intro/site/home
or
http://localhost/ci_intro/site/about
有这么控制器,在这种情况下网站,从网址中移除完全是作为使用网站/家庭或网站/在我看来,链接有关绕过这种方法的任何已知的方式似乎没有工作?
感谢您的回复。我明白你从URL中删除控制器的意思,因为它可能会导致在开发过程中丢失范围。但是,如果是这种情况,我该如何去关联我的观点?如果我使用网站/家庭或网站/关于这是第一次罚款,我点击其中一个,但下一次它链接到网站/网站/约。 – jezzipin 2013-04-25 14:07:46
检查application/config.php中的$ config ['base_url']'并设置它。 – stormdrain 2013-04-25 14:10:11
在这种情况下,我猜这是localhost/ci_intro? – jezzipin 2013-04-25 14:11:39