Philippe Carriere
Philippe Carriere

Reputation: 3720

Hide index.php (or index.html) of an URL

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 .

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.

Upvotes: 8

Views: 22965

Answers (4)

ADC
ADC

Reputation: 21

This seemed to work in my environment (would NOT display index.php):

        <form action="." method="POST">
       E-mail: <input type='password' size='50' name='email' />
       <input type='submit' value='Login' />
    </form>

Upvotes: 2

Thinker
Thinker

Reputation: 14464

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.

Upvotes: 9

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181350

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.

Upvotes: 4

Kris Erickson
Kris Erickson

Reputation: 33844

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.

Upvotes: 1

Related Questions