0

I need to send a user to "/index.php" when they don't specify a file in the URL.

This is probably a really simple fix because I know it's a common problem, and I've tried multiple answers on SO, though they didn't work.

Here's what some examples of what I've tried

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php

OR

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [NC,L,QSA]

OR

DirectoryIndex index.php

This is the rest of the htaccess file which I need to whitelist a few files that should be open, everything else should not be accessed.

Order deny,allow
Deny from all
<FilesMatch "index\.php|logout\.php|login\.php|main\.css|logo2\.png|bg\.jpg|logoAuth\.png|favicon\.ico|grafikk_venstreNede\.png|grafikk_hoyreMidt\.png">
  Allow from all
</FilesMatch>

Expected result is calling "domain.com" and the server responds with "domain.com/index.php"

Any help would be greatly appreciated!

Philip Aarseth
  • 301
  • 4
  • 16

1 Answers1

0

Set DirectoryIndex index.php in either your apache config file or in the .htaccess file.

Ole Wolf
  • 1,312
  • 13
  • 18
  • Adding it to before or after the other code part doesn't work. – Philip Aarseth Feb 01 '19 at 10:52
  • just to be clear, this ```DirectoryIndex index.php Order deny,allow Deny from all Allow from all ``` doesn't work, you would just get "Forbidden You don't have permission to access / on this server." – Philip Aarseth Feb 01 '19 at 10:54