Access files with no extension in apache 2.4


Recommended Posts

I have a Debian server and I built Apache 2.4 myself. With Apache 2.2, installed with apt-get, my directory looked like this:

index.html forums.html wiki.html

And I could link to forums.html by linking to /forums. However, with this new server, I can no longer do this. Is there a config option I can change to do this?

Link to comment
Share on other sites

it known as URL Rewriting

 

you can do it by adding this to your .htaccess file

#turn on url rewriting 
RewriteEngine on


#remove the need for .php extention 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php
This allows you to access .php files without the extension, so your links should read
href="/somepage"
and this will direct to
href="/somepage.php" 
  • Like 1
Link to comment
Share on other sites

This topic is now closed to further replies.