menu

The .htaccess file

.htaccess for la.plume micro CMS

From 21st November 2018 the following .htaccess file is already in the website root folder:

ErrorDocument 404 /error404.php
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^(.*)$ $1.php
</IfModule>
Options -Indexes

Previously the file was only created during 'Setup' and the process was more complicated, involving a check whether the CMS was being installed on Apache Web Server and the inclusion of lines containing the full url.

The main point is to eliminate the need for a .php file suffix to be on the end of each url, but it can only be done on Apache with the mod_rewrite module enabled by the server administrator. Most Apache / Linux type servers now have the module enabled so it shouldn't be an issue.


eg: https://www.yourwebsite.com/page


If la.plume micro CMS is installed on a Windows server (or Nginx) the .htaccess file will not be recognised and have no effect. It may as well not exist and should be deleted or preferably not uploaded in the first place.

The .htaccess file should work on most Apache / Linux type web hosting packages and the CMS will automatically rewrite non .php urls to the actual .php page files on the server. Note that except for the home page, all the other pages can still be viewed with the file extension if .php is added to the end of the url. It means that each page effectively has two different urls, which mattered at one time but I don't believe it does now. To prevent the .php-suffixed url from ever being accessed, edit the file to include the two following lines and upload it again:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/.]+)\.php\ HTTP/
RewriteRule ^([^/.]+)\.php$ https://www.yourwebsite.com/$1 [R=301,L]

The .htaccess file will be:

ErrorDocument 404 /error404.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/.]+)\.php\ HTTP/
RewriteRule ^([^/.]+)\.php$ https://www.yourwebsite.com/$1 [R=301,L]
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^(.*)$ $1.php
</IfModule>
Options -Indexes

Details about the previous .htaccess file are here. The additional lines can be added back manually if required.

Note 1

If the CMS detects there is no .htaccess file but the server is Apache it will automatically include the .php file suffix at the end of each url:


eg: https://www.yourwebsite.com/page.php


Note 2

If the CMS detects there is no .htaccess file and the server is not Apache it will automatically include the .php file suffix at the end of each url. It will also assume the server is Windows IIS and disable the contact page and the comment facility, both of which rely on PHP's mail function. As far as I know it is not supported on Windows.

Note 3

Make sure at the outset that any internal links written into the pages are consistent with the setup — in other words, all with or all without a .php file suffix. If they have the suffix they should always work. If not they will work on Apache only with a functioning .htaccess.

Downloads since Sept 2011: 18,224