简体   繁体   中英

Why DirectoryIndex index.php index.html is not working?

I currently use ipage as a host and have a domain pointing to an index.html. However, I need the domain to point to an index.php instead. So I created a .htaccess and only wrote; DirectoryIndex index.php index.html and saved it but it's not working and users are still being directed to index.html. There is one issue and that index.php is inside a folder called "SourceFolder". So I think the server looks for index.php and can't find it.

So your default 'root' directory of the website has a folder in it called SourceFolder, and the index.php file is in there?

If so, then simply do the following inside htaccess.

DirectoryIndex SourceFolder/index.php

This will look for index.php inside SourceFolder.

Your DirectoryIndex directive is fine but you need to route request to correct folder.

Have this code in root .htaccess:

DirectoryIndex index.php index.html

RewriteEngine On

RewriteRule !^SourceFolder/ SourceFolder%{REQUEST_URI} [L,NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM