htaccess is a configuration file for use on web servers running on the web apache server software. when a . htaccess file is placed in a directory which in turn loaded via the Apache web server, then the . htaccess file detected and executed by the Apache server software.
The index. php file for a template contains a mixture of code that will be delivered as it is, and php code, which will be modified before it is delivered. The code will be familiar to anyone who has designed a simple html webpage: there are 2 main sections - the <head> and <body>. Where index.
Apache needs to be configured to recognize index.php as an index file.
The simplest way to accomplish this..
Create a .htaccess file in your web root.
Add the line...
DirectoryIndex index.php
Here is a resource regarding the matter...
http://www.twsc.biz/twsc_hosting_htaccess.php
Edit: I'm assuming apache is configured to allow .htaccess files. If it isn't, you'll have to modify the setting in apache's configuration file (httpd.conf)
While adding 'DirectoryIndex index.php' to a .htaccess file may work,
NOTE:
In general, you should never use .htaccess files
This is quoted from http://httpd.apache.org/docs/1.3/howto/htaccess.html
Although this refers to an older version of apache, I believe the principle still applies.
Adding the following to your httpd.conf (if you have access to it) is considered better form, causes less server overhead and has the exact same effect:
<Directory /myapp>
DirectoryIndex index.php
</Directory>
Edit: At the time of edit, the v1.3 documentation is down. The v2.4 documentation (current version at time of edit) has a similar stance:
In general, use of
.htaccess
files should be avoided when possible. Any configuration that you would consider putting in a.htaccess
file, can just as effectively be made in a<Directory>
section in your main server configuration file.
At a guess I'd say the directory index is set to index.html, or some variant, try:
DirectoryIndex index.html index.php
This will still give index.html priority over index.php (handy if you need to throw up a maintenance page)
This might be helpful to somebody. here is the snippet from httpd.conf (Apache version 2.2 windows)
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
DirectoryIndex index.php
</IfModule>
now this will look for index.html file if not found it will look for index.php.
This post might be old but i am just posting it incase it helps some other person, I would not advise to Create a .htaccess file in your web root and change the index. I feel it is better to follow the steps
Go to the conf folder of your apache folder mine is
C:\Apache24\conf
Open the file named
httpd.conf
Go to the section
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Add index.php to it as shown below
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
This way, it still picks index.html and index.php as the default index but giving priority to index.html because index.html came before *index.php. By this I mean in you have both index.html and index.php in the same directory, the index.html will be used as the default index except you write **index.php* before index.hml
I hope it helps someone... Happy Coding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With