I need, but don't know how to make, an htaccess file that will send a user, when looking for the home page, to index.php. It should not send them anywhere when they look for a URL like /7fg4/.

Adfly, to the best of my knowledge, works like this: you make a link, it stores the shortened link. When the user tries to open the link the htaccess file sends them the contents of another file which reads the URL and proceeds accordingly. My website should work almost exactly as Adfly does.

Can anyone explain or write an htaccess file that would do this?

  • I suggest you read into the basics of URL rewriting. Or do you have any specific problem?
    – lawl0r
    Commented Feb 17, 2012 at 22:50

1 Answer 1


You want to implement permanent redirects in .htaccess. To redirect the home page to default.php you need:

redirect permanent index.html http://example.com/default.php

index.html is the default document on most servers. To redirect the home page, you have to redirect the default document. In that rule, you would need to replace example.com with your own domain name.

Instead of redirecting the home page to default.php, I would recommend making that file your home page. To do so, you have to change the default document with a directive like this:

DirectoryIndex default.php

Then the contents of default.php will be served at the home page and users will never see default.php in the URL.

Your Answer

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