Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache doesn't execute script of index.php in root automatically

Tags:

http

php

apache

This is strange: my Apache is configured with DirectoryIndex index.html,index.php so when I type http://gustavopi-macmini.local/ it searches for index.php and loads it ok if there is only html tags in the file.

But if I put some php script in index.php, it loads index.html.en instead (It Works!). However, if I type http://gustavopi-macmini.local/index.php it loads and executes the script.

Also, if I put an index.php file in a subdirectory and type http://gustavopi-macmini.local/somesubdirectory/ it loads and executes index.php normally as it should...

Why this strange behavior of "jumping" from a php script in the root occurring?

like image 923
Gustavo Avatar asked Jul 17 '26 17:07

Gustavo


1 Answers

The order of the defined 'directory index' files also determine their priority.

In your situation, if both an index.html and a index.php are present, Apache will pick the index.html.

To change this, change the order of the 'directory index' files;

DirectoryIndex index.php index.html

Read the documentation here:

http://httpd.apache.org/docs/2.2/mod/mod_dir.html

like image 173
thaJeztah Avatar answered Jul 20 '26 06:07

thaJeztah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!