I have website http://mywebsite.com If I hit this URL it take index.php and index.html as default page. How can I make home.php as default page. I have tried this but not wo
Just try to rewrite /index.html
and /index.php
into /home.php
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/index\.(html|php)
RewriteRule ^(.*) /home.php
You need AllowOverride +Indexes
in your httpd.conf
to be able to use DirectoryIndex
in .htaccess
.
Barring that, the absolutely easiest way to redirect (without the root access to Apache config and modules) is putting this as index.html
:
<!doctype html>
<html>
<head>
<meta http-equiv="Refresh" content="0; url=home.php">
</head>
<body>
</body>
</html>
You just need home.php
in your DirectoryIndex
to make it works. Remember that this is using in .htaccess file of your root project:
DirectoryIndex home.php
DirectoryIndex directive applies to all subfolders, if you want set diffrent files for each directories, you can use mod-rewrite.
To set /file.html as root directory handler, you can use this at the top of your htaccess :
RewriteEngine on
RewriteRule ^$ /file.html [L]
To set a diffrent file as index for a subfolder, use this :
RewriteEngine on
RewriteRule ^subfolder/$ /myfile.html [L]