Welcome Guest, Not a member yet? Register   Sign In
Getting rid of index.php
#1

[eluser]Unknown[/eluser]
Hi,

I'm making a digg-like site with CodeIgniter, and I have to say, I love it! But, the whole index.php in the URL is really starting to bother me. Take this URL:

http://www.example.com/index.php/popular/all

As opposed to:

http://www.example.com/popular/all

The second one looks much better, yes? I looked at the User Guide where it says how to do some mod_rewrite magic to change this, but to no avail.

Help?
#2

[eluser]Yadi Utama[/eluser]
I think you have to make a .htaccess file into your root folder. Insert the list of codes below into your .htacces file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

But, you have to set the httpd.conf in your Apache webserver first as following instruction:
1. Make sure to unblock this line of code in your httpd.conf:

LoadModule rewrite_module modules/mod_rewrite.so

2. Check the following code in your httpd.conf

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride all

3. Make sure to unblock "AllowOverride All" as shown above. So it will be:
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all

4. Restart your httpd service

I think it will work as i have ever done with it. Good luck but i'm sorry because of my english not good.
#3

[eluser]R. Oerlemans[/eluser]
http://codeigniter.com/wiki/mod_rewrite/

That page might be useful.
#4

[eluser]Unknown[/eluser]
Thanks guys. Everything's working now.




Theme © iAndrew 2016 - Forum software by © MyBB