Remove index from url

#1
[eluser]Suhas nazir[/eluser]
Can any one please tell how to remove index from the url for eg:
localhost/hope/index.php/mycontroller
instead of this i want to use link as localhost/hope/mycontroller

#2
[eluser]rainbowrams[/eluser]
By default, the index.php file will be included in your URLs

example.com/index.php/news/article/my_article

You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:

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

In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.

you can check the same thing in user guide

http://ellislab.com/codeigniter/user-gui.../urls.html

#3
[eluser]Suhas nazir[/eluser]
I just found this but i dnt understand what it means can u please tell me a simple example

#4
[eluser]proximityfuse[/eluser]
I have the problem that I have a .htaccessfile but index.php still doesn´t go away. I have tried different code in the .htaccessfile and i have also made changes in the config.php file, but the index.php still doesn´t disappear. Do you have any suggestions why it is so?

#5
[eluser]Suhas nazir[/eluser]
@proximityfuse
I found a solution for this .I just found this from an article.you try this
create a file and save it as .htaccess and paste the below code

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]


Now change the config file as $config['index_page']="" (by default it contains index so change it as "")

and then check whether in the view file u write index.php in form tag,if u used there then remove that index.php from there.
if u are using codeigniters form_open then u dont need to change any thing
Try this Best wishes....

#6
[eluser]proximityfuse[/eluser]
Thank you for you advice Sas, but I get Internal Server Error.

#7
[eluser]ndchris[/eluser]
[quote author="proximityfuse" date="1277922262"]Thank you for you advice Sas, but I get Internal Server Error.[/quote]

Are you sure that mod_rewrite is available and enabled in your servers config?
There should be something like:
Code:
LoadModule rewrite_module modules/mod_rewrite.so

Or perhaps there's a "AllowOverride FileInfo" directive missing in your <Directory> in httpd.conf.

Maybe that'll help.

If you get a 403 then, add "Options +FollowSymlinks" in your <Directory> area.

#8
[eluser]proximityfuse[/eluser]
Yes I had to enable the rewrite module for the Appache server. Now it works and index.php has disappeared. Thank you for you advice ndchris.

But if i develop a application in CodeIgniter and want to upload it will it not be a problem for me that i have to have special server configs that I'm maybe not able to change. The host maybe even doesn't have mod_rewrite enabled which would mean that i have a limited number of host to choose from that take that have such special settings that will allow me to have codeigniter there witch my own configurations is could that be right?

#9
[eluser]ndchris[/eluser]
You're welcome. The majority of hosting providers already have mod_rewrite enabled and support .htaccess files in their configs.
So I would say it isn't a problem.

#10
[eluser]Suhas nazir[/eluser]
Hai all try this also i dnt know this is the answer for ur question
anywise try

In some case the default setting for uri_protocol does not work properly. To solve this problem just replace
$config['uri_protocol'] = “AUTO” by $config['uri_protocol'] = “REQUEST_URI” from system/application/config/config.php


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.