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 />
| SitePoint Sponsor |
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 />
Last edited by guido2004; Dec 5, 2011 at 05:23. Reason: no need for url
Looks like a rewrite question to me. Moved to the apache forum.
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget


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:
If you're interested in the POWER that regular expressions give a webmaster, have a look at the tutorial Article linked in my signature.Code:# 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)
Regards,
DK
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
1. add index.html on your DirectoryIndex configuration of your vhost or httpd.conf
or.
2. 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
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator


Hi,
Try use this code in .htaccess:
- replace "domain.net" with your site name.Code:#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
Code:<meta http-equiv="refresh" content="0;url=index.php" />
Free: Web Programming Courses HTML, CSS, Flash
Web Programming: AJAX Course and PHP-MySQL Course video Lessons
Good JavaScript and jQuery course for beginners

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
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator


Thank you for correction, we allways have something to learn.
Free: Web Programming Courses HTML, CSS, Flash
Web Programming: AJAX Course and PHP-MySQL Course video Lessons
Good JavaScript and jQuery course for beginners

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
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
Bookmarks