I want that when I click on a link like this: <a href="settings/">Settings</a>
it will go to the subdirectory, and load index.php
. When I try this right now I get a 404 error
It works if the link is as so: <a href="settings/index.php">Settings</a>
but I don't want index.php
in the url.
Does anybody know how can I write an .htaccess
rule to achieve this ?
.htaccess
DirectoryIndex index.php index.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Oh you just mentioned .htaccess
, now i can answer. You just need to edit your DirectoryIndex
directive. Add this to your .htaccess
DirectoryIndex index.php index.html
I added a comment before answering because you didn't specify the web server. After your comment mentioning .htaccess
its surely apache and this solution is for apache. You can either edit your config file or add that to your .htaccess
This directive tells apache to use index.php
as the directory index first and if it cant find that then look for index.html