Welcome Guest, Not a member yet? Register   Sign In
Hiding index.php When Using site_url()
#1

[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?
#2

[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
#3

[eluser]Unknown[/eluser]
Thanks Dam1an!

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

[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
#5

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

[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>
#7

[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]
#8

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

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

[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




Theme © iAndrew 2016 - Forum software by © MyBB