How to set the default website page through htaccess?
Solution 1
Use the DirectoryIndex directive in your .htaccess file
DirectoryIndex index.php
Solution 2
The problem was caused by my web-browser cache, as soon as I have cleared my cache it worked!
Solution 3
Try
DirectoryIndex index.php
if that doesn't work you might have to work around it by providing index.html like
<html><frameset rows="*"><frame src="index.php"></frameset></html>
(ofcourse more elaborate)
Solution 4
You can set your default page as the directory index using .htaccess file in 2 ways.
First method
DirectoryIndex yourfile.php
Above code will set 'yourfile.php' as the directory index. But this will applies to all sub folders as well and may occur '404' error for some related urls.
Second method
Use this code to set your handler file for the root directory
RewriteEngine on
RewriteRule ^$ /yourfile.php [L]
If you want to set a handler file for the sub folder, use this one
RewriteEngine on
RewriteRule ^subfolder/$ /yourfile.php [L]
perpetual_dream
I am the co-founder and the web development specialist at Beyond Designs, a web development shop located in Jerusalem. In addition, I constantly blog about web hosting, domain names and CMS on Linux Hosting.
Updated on July 12, 2022Comments
-
perpetual_dream almost 2 years
I am currently setting up a website from a client on his hosting account. The website address and for some reason doesn't default to .php files (that is: index.php). If I put index.php and there is no index.html file I receive the following error:
If you feel you have reached this page in error, please contact the web site owner: [email protected] If you are the web site owner, it is possible you have reached this page because: The IP address has changed. There has been a server misconfiguration. The site may have been moved to a different server. If you are the owner of this website and were not expecting to see this page, please contact your hosting provider.
His hosting is a shared hosting on cpanel.