8

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.

2
  • I re-tagged the question, removing 'hide' and replacing with 'mod-rewrite' as I think that's probably more relevant. I'm happy to be proven wrong, though =) Commented Aug 17, 2009 at 15:43
  • What do you mean by redirecting? Is it an external redirect (the URL changes) or an internal redirect (request of / returns the same as /index.php)? Commented Aug 17, 2009 at 15:45

4 Answers 4

9

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Agree. You don't need MOD_REWRITE for such a simple thing.
I'll try that and come back to you.
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.
Check the place, where you've been refered to your server. It can be wrong httpd configuration.
4

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.

1 Comment

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.
2

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>

Comments

1

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.

2 Comments

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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.