CodeIgniter Forums
Hiding index.php When Using site_url() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Hiding index.php When Using site_url() (/showthread.php?tid=18368)

Pages: 1 2 3


Hiding index.php When Using site_url() - El Forum - 05-04-2009

[eluser]Unknown[/eluser]
What I would like to do is hide the index.php portion of the URL generated by the site_url() function.

The .htaccess file works fine, and I would also like to still be able to support parameters (index.php?a=b&c=d etc...).

Is this possible with CodeIgniter? If so, how would I go about doing this?


Hiding index.php When Using site_url() - El Forum - 05-04-2009

[eluser]Dam1an[/eluser]
site_url builds the url based on the values of base_url and index_page in the config file
To get rid of the index.php in the URl, change index_page to nothing

You can also enable quiry strings by changing settings in the config file, but you then lose the ability to use URI segments

See the user guide for more


Hiding index.php When Using site_url() - El Forum - 05-04-2009

[eluser]Unknown[/eluser]
Thanks Dam1an!

Your suggestion about removing the "index.php" in the config file works.


Hiding index.php When Using site_url() - El Forum - 07-30-2009

[eluser]bluepicaso[/eluser]
Help me please.
i was unable to do it.
This is what is have:

$config['base_url'] = "http://localhost/kids/";
$config['index_page'] = "";
but still typing this http://localhost/kids/Upload in the url doent work.......
what works is this http://localhost/kids/index.php/Upload


Hiding index.php When Using site_url() - El Forum - 07-30-2009

[eluser]Dam1an[/eluser]
have ypou created the .htaccess file?


Hiding index.php When Using site_url() - El Forum - 07-30-2009

[eluser]bluepicaso[/eluser]
yes i have it says this

Options -Indexes
Options +FollowSymLinks
Options -MultiViews
DirectoryIndex index.php

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
#<IfModule !mod_rewrite.so>
ErrorDocument 404 index.php
</IfModule>


Hiding index.php When Using site_url() - El Forum - 07-30-2009

[eluser]jedd[/eluser]
That looks very complicated.

Mine is thus:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|files|assets|robots\.txt)
RewriteRule ^(.*)$ ./index.php/$1 [L]



Hiding index.php When Using site_url() - El Forum - 07-30-2009

[eluser]bluepicaso[/eluser]
ok lets c
Does you works correctly fine?


Hiding index.php When Using site_url() - El Forum - 07-30-2009

[eluser]jedd[/eluser]
Better than yours, by the sounds of it.


Hiding index.php When Using site_url() - El Forum - 07-30-2009

[eluser]bluepicaso[/eluser]
Hello,
now let me clear the full scenario
My config.php file has this

Code:
$config['base_url']    = "http://localhost/kids/";
$config['index_page'] = "";
$config['uri_protocol']    = "AUTO";

My .htaccess file has this

Code:
<IfModule mod_rewrite.so>
    RewriteEngine on
    RewriteBase /kids/
     RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /kids/index.php/$1 [NC,L,QSA]
</IfModule>

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

In the code above i have found that
if i type

http://localhost/kids/index.php/upload

The page is displayed
but as i type

http://localhost/kids/upload

it just says "index.php" as a text on the page

So the .htaccess file is following
this only.
Code:
<IfModule !mod_rewrite.so>
     ErrorDocument 404 index.php
</IfModule>


I even changed the httpd.conf file

Code:
#LoadModule rewrite_module modules/mod_rewrite.so
to
LoadModule rewrite_module modules/mod_rewrite.so


but still nothing is changing