How can i set my sites index.html to home page?

I have a PHP based sites .i want to redirect index.html page to home page .how can i do .i have tried many time but it give error
my sites is this :- <snip />

Looks like a rewrite question to me. Moved to the apache forum.

If your home page is index.php, just delete index.html from the server and your index.php will be automatically picked up as the home page. Not quite sure what you are trying to do exactly so sorry if this is not what you were looking for.

elwin,

chilli11’s answer is true only with a caveat: Your DirectoryIndex must be set to index.html index.php {anything else}.

Somehow, I don’t believe this is a mod_rewrite question (redirect a specific filename to a different filename) so you have several choices depending upon your real intention:

# DirectoryIndex solution, i.e., specify the default files to be served in order of appearance
DirectoryIndex index.php index.html index.htm default.asp

# mod_alias (Apache core) solution
Redirect 301 index.htm /index.php
# here, the redirection is specified to be permanent (301 code) and the redirection MUST be an absolute URI/URL

# mod_rewrite solution
RewriteEngine on
RewriteRule ^index\\.html?$ index.php [R=301,L]
# here the regular expression will capture index.htm or index.html
# (? denotes that the previous character is optional),
# ^ is the start anchor (the beginning of the {REQUEST_URI} string),
# $ is the end anchor (the end of the {REQUEST_URI} string}, 
# R=301 is a permanent redirection and L says to end that RewriteRule set
# (the set can be "attached" to RewriteCond and other RewriteRule statements)

If you’re interested in the POWER that regular expressions give a webmaster, have a look at the tutorial Article linked in my signature.

Regards,

DK

  1. add index.html on your DirectoryIndex configuration of your vhost or httpd.conf

or.

  1. create a index.html and add a redirect on it ex:
    <?php
    header(“HTTP/1.1 301 Moved Permanently”);
    header(“Location: http://www.abc.com/”);
    exit();
    ?>

tric,

Aw, if you do this, you’ll need to add an AddHandler so PHP will know to parse and run the code in an .html file. Obviously, the DirectoryIndex is the preferred (and intentionally so) way to have index.php loaded as the default script (if it’s available).

Regards,

DK

Hi,
Try use this code in .htaccess:

#RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^domain.net/index.html$ domain.net/index.php [R=301]

If not work, you can use this html meta tag in the header of the index.html

<meta http-equiv="refresh" content="0;url=index.php" />

MarPlo,

VERY bad recommendation - primarily because the RewriteRule can only examine the {REQUEST_URI} Apache variable (which will never contain the domain name). Further, the RewriteBase (which is commented out) is totally irrelevant (no mod_alias Redirects to “undo”) and the question (and solution) has nothing to do with the requested file being a file or directory which exists.

Regards,

DK

Thank you for correction, we allways have something to learn.

MarPlo,

No worries, mate!

What you were showing was the standard CMS (WP) mod_rewrite code which redirects EVERYTHING except existing files and directories to index.php. Nice as a 404 handler but that wasn’t the question that was asked. On the other hand, the DirectoryIndex Apache core directive was designed to give a “shopping list” of files for Apache to check for in the event only a directory was specified, ergo, that’s the directive to use.

Regards,

DK