Search code examples
php.htaccesshttp-redirectindexingdirectoryindex

DirectoryIndex not assigning new default directory


I just got finished changing my entirely static HTML website into a PHP one to allow editing ease. I used a 301 RedirectMatch in my .htaccess file so direct all the .html pages to the new .php ones. However, when I did this, it decided to change my default directory from index.php (was already php for a while) to default.php. I don't even have a file named default.php. Anyways, I tried to add a DirectoryIndex line into my .htaccess to change it back to index.php, but it's still doing to default.php.

Here's my .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RedirectMatch 301 (.*)\.html$ http://www.fifaencyclopedia.com$1.php
DirectoryIndex index.php

What am I doing wrong? How do I fix this?

EDIT: I just made a default.php page so there's something there, but I'd rather it be index.php.

EDIT: GerManson, moving it to the top did not work :(


Solution

  • are the redirections working propertly?

    you may need to set AllowOverride All on your virtual host configuration.

    if its is a shared hosting, it may be the case that the redirections are working before the DirectoryIndex directive. just move it to the top