views:

1700

answers:

4

When I type the address of my site in a browser (mysite.com), it redirects to mysite.com/index.php. Why not to index.html ? Because I changed it in the conf file in Apache 2.2 .

  • Now I would like to hide the last "index.php" part. How do I do that ?
  • Would it be different it was index.html than index.php ?

Wouldn't be ugly if by looking for google, you would end up on www.google.com/index.html ? ... it's just for esthetics but god is it important to certain people.

+1  A: 

You can easily do this with URL mapping in either the http.conf file or individual .htaccess files in your application directories. Turn on mod rewrite. Here is a simple tutorial.

Kris Erickson
I like your answer but I think Pablo Santa Cruz and Thinker are right : I don't need to go in that deep to solve my specific issue. Don't need a cannon to kill a fly.
Silence
Agreed, if you only want to handle index.html then that is correct. If you have more than one "control" page, you need mod_rewrite.
Kris Erickson
+3  A: 

If it's redirecting, (by sending a new Location on HTTP header, for example) then there's nothing you can do but changing the code that's doing the redirect.

On the other hand, if your WebServer is Apache, there is a configuration directive that might help:

DirectoryIndex

When you set that to: index.php or index.html, then your web server will automatically redirect to those internal files without changing the URL when you hit the directory on your server where the DirectoryIndex directive is setup.

I guess you'll get better answers if you post this on SERVERFAULT.

Good luck.

Pablo Santa Cruz
I may have been unclear but the part that said "I changed it in the conf file in Apache" meant exactly that. It is set to index.php.
Silence
+4  A: 

I don't know why you need to use mod_rewrite. On my site I did nothing to hide index.php, I just don't point it anywhere in code, so instead of www.example.com/index.php?task=forum I just write www.example.com/?task=forum. It works on standard apache config.

Thinker
Agree. You don't need MOD_REWRITE for such a simple thing.
Pablo Santa Cruz
I'll try that and come back to you.
Silence
Hmmm I'm a bit confused... I refer the index.php later in some other code but it shouldn't matter. When I write mysite.com, I'm being refered to my server machine which is running apache. Apache then display the index.html. But I never reference to it specifically.
Silence
Check the place, where you've been refered to your server. It can be wrong httpd configuration.
Thinker
Finally worked. Thank you. Sorry for the delay.
Silence
+1  A: 

I hope the following link will help you a lot:

http://www.anmsaiful.net/blog/php/remove-codeigniter-index-php.html

Saiful
Why the serial downvoting of Saiful answers ?
Silence
He is just spamming a link to a post in his blog. He is not reading each individual question and giving a thoughtful answer. Also answers are supposed to be on SO, so when people search for the same question they can see the answer here. If his site goes down, domain expires, URLs change, then no one will see the 'answer'.
mrinject
True. Thanks for the explanation.
Silence