EllisLab text mark
Advanced Search
     
.htaccess sample code not working (hiding index.php)
Posted: 28 October 2007 12:28 PM
Avatar
Joined: 2007-10-28
2 posts

I’ve read through the forum and have tried many of the things people have suggested but I have had no luck hiding the “index.php” from my url on my local machine or webserver.

I’d first like to get this working on my local Ubuntu Apache server and yes mod_rewrite is enabled.

My test app is installed at: http://192.168.1.100/ipaw/

In my config file I have:
$config[‘base_url’]  = “http://192.168.1.100/ipaw/”;
$config[‘uri_protocol’]  = “AUTO”;

My .htaccess is as follows:

RewriteEngine on
RewriteBase /ipaw
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Any link I click on ends up showing the index.php in the url, ie:
http://192.168.1.100/ipaw/index.php/contact_me

Does anyone have any ideas to help this CodeIgniter newbie out?

Thanks

 
Posted: 28 October 2007 12:38 PM   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-08-03
52 posts

In my config file I have:
$config[’base_url’] = “http://192.168.1.100/ipaw/”;
$config[’uri_protocol’] = “AUTO”;

In your config file do you change

$config[‘index_page’] = “”;

Thanks
Saidur Rahman
Developer
Right Brain Solution

 
Posted: 28 October 2007 12:42 PM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-20
35 posts

This is what my .htaccess looks like; I ended up needing to put a / in front of RewriteRule stuff:

<IfModule mod_rewrite.c>
    
Options +FollowSymLinks
    RewriteEngine On
    RewriteCond 
%{REQUEST_FILENAME} !-f
    RewriteCond 
%{REQUEST_FILENAME} !-d
    RewriteRule 
^/(.*)$ /index.php/$1 [QSA,L]
</IfModule
 Signature 

PHP + CodeIgniter LOL

 
Posted: 28 October 2007 02:53 PM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-28
2 posts

Thanks bijon! I had $config[‘index_page’] = “index.php”;

Once left blank all works as expected.

Cheers

 
Posted: 02 November 2007 07:09 AM   [ # 4 ]   [ Rating: 0 ]
Joined: 2007-11-02
21 posts

Hi

i got the same problem, altough i read the config file so i made

$config['index_page'""

blank

my config file is as follows:

$config['base_url']    "http://127.0.0.1/shop/";
$config['index_page'"";
$config['uri_protocol']    "AUTO"

.htaccess

RewriteEngine on
RewriteBase 
/shop
RewriteCond 
$!^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L] 

thx for helping me out. starenka

 
Posted: 02 November 2007 03:35 PM   [ # 5 ]   [ Rating: 0 ]
Joined: 2007-08-03
52 posts

Hi starenka,
I am not sure why it does not work. It seems that everything ok.
The to remove index.php from the url is very disgusting problem. There is not a specific reason why it does not work. It depends on lot of things. Your hosting server configuration. Also it depends on apache mod rewrite configuration and to change CI config file.

So from the forum what i find useful post , i listed below. So check them and try . I hope you will be able to do that . Then post you how you do that .

wiki tutorial :
http://codeigniter.com/wiki/mod_rewrite/

forum post :
http://ellislab.com/forums/viewthread/62100/
http://ellislab.com/forums/viewthread/62797/
http://ellislab.com/forums/viewthread/62797/
http://ellislab.com/forums/viewthread/63008/

hosting server :
http://codeigniter.com/wiki/Dreamhost_.htaccess/
http://codeigniter.com/wiki/Godaddy_Installaton_Tips/

 
Posted: 03 November 2007 05:29 AM   [ # 6 ]   [ Rating: 0 ]
Joined: 2007-11-02
21 posts

well, the problem seems to be in .htaccess file - now i pasted the code from wiki tutorial:

<IfModule mod_rewrite.c>
    
RewriteEngine On
    RewriteBase 
/shop/
    
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.
    # Submitted by: ElliotHaughin

    
ErrorDocument 404 /index.php
</IfModule

and voila!

thx bijon