Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving index.php in Codeigniter 2
    text
    copied!<p>I'm having some trouble using Codeigniter2. Essentially I want to remove the annoying "index.php" from my url so that:</p> <pre><code> - http://localhost/ci_intro/index.php/site/home Becomes - http://localhost/ci_intro/home </code></pre> <p>I've followed a couple of the links on Stack Overflow already and have found the following two posts:</p> <p><a href="https://stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2">Remove index.php From URL - Codeigniter 2</a></p> <p>And</p> <p><a href="https://stackoverflow.com/questions/11016778/removing-index-php-from-codeigniter-2">Removing index.php from codeigniter-2</a></p> <p>However after performing both steps still no joy.</p> <p>My .htaccess is as follows:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; 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] &lt;/IfModule&gt; &lt;IfModule !mod_rewrite.c&gt; # 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 &lt;/IfModule&gt; </code></pre> <p>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.</p> <p>I have two views in CodeIgniter2, one called Home and another called About. These two link to each other. The links are as follows:</p> <pre><code> &lt;a href="home"&gt;Home&lt;/a&gt;&lt;br/&gt; &lt;a href="about"&gt;About&lt;/a&gt; </code></pre> <p>If I go to the root URL of my project:</p> <pre><code> http://localhost/ci_intro/ </code></pre> <p>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:</p> <pre><code> http://localhost/ci_intro/home or http://localhost/ci_intro/about </code></pre> <p>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:</p> <pre><code> http://localhost/ci_intro/site/home or http://localhost/ci_intro/site/about </code></pre> <p>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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload