how to make default page home.php instead of index.html and index.php

后端 未结 4 461
春和景丽
春和景丽 2020-12-09 04:15

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

相关标签:
4条回答
  • 2020-12-09 04:51

    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
    
    0 讨论(0)
  • 2020-12-09 04:55

    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>
    
    0 讨论(0)
  • 2020-12-09 05:07

    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
    
    0 讨论(0)
  • 2020-12-09 05:07

    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]
    
    0 讨论(0)
提交回复
热议问题