I'm having some trouble using Codeigniter2. Essentially I want to remove the annoying "index.php" from my url so that:
- http://localhost/ci_intro/index.php/site/home
Becomes
- http://localhost/ci_intro/home
I've followed a couple of the links on Stack Overflow already and have found the following two posts:
Remove index.php From URL - Codeigniter 2
And
Removing index.php from codeigniter-2
However after performing both steps still no joy.
My .htaccess is as follows:
<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>
I've ensured that the mod_rewrite module is enable in Apache (I'm using Xampp on Windows) but for some reason it's just not working as i'd expect it to.
I have two views in CodeIgniter2, one called Home and another called About. These two link to each other. The links are as follows:
<a href="home">Home</a><br/>
<a href="about">About</a>
If I go to the root URL of my project:
http://localhost/ci_intro/
The index function of the Home page is displayed. That's fine and as expected. However, if I then click either link it redirects to:
http://localhost/ci_intro/home
or
http://localhost/ci_intro/about
Which produces a 404. However if I then type "site" in the URL, the name of my controller, the links take me through to the correctly loaded views:
http://localhost/ci_intro/site/home
or
http://localhost/ci_intro/site/about
Is there any known way of bypassing this approach so that the controller,in this case site, is removed from the URL entirely as using site/home or site/about in the links in my view does not appear to work?