Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 403
user3626925 Avatar asked Sep 15 '25 20:09

user3626925


2 Answers

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]
like image 50
anubhava Avatar answered Sep 17 '25 10:09

anubhava


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.

like image 33
Chris Evans Avatar answered Sep 17 '25 10:09

Chris Evans