menu

The .htaccess File

.htaccess for la.plume micro CMS

la.plume micro CMS requires a new .htaccess file in the 'root' installation folder. This file is written when admin/setup is submitted. That is why the system should be installed on Apache web server, not Windows IIS server (Windows does not support the use of .htaccess). Some hosting accounts, even on Apache, do not allow the writing or customisation of .htaccess - the file may already exist but is not writeable. In these cases the system will not run properly. The file must be writeable. On most modern web hosting packages it is, but not always.

If you can't see the .htaccess file...

On some web hosting packages the .htaccess file is not visible using an FTP client program. This can often be corrected by enabling server side filtering in the FTP client program and setting the remote filter as -rtaF. The precise details may vary from one program to another.

On a Mac it is probably invisible by default. To view it, install textwrangler, a free text editor for Macintosh that displays the .htaccess file. On Windows you may need to configure your computer to "Show hidden files."

More about Apache web server and .htaccess is available at WebmasterWorld's Apache web server library »

From version 5.7 the system can be run with no .htaccess file. If an .htaccess file is not present the pages display in their native folder (/cms/) and with a .php file extension. If the .htaccess file is present (and writeable) the system runs normally, without /cms/ in the URL path and no .php file extension.

The .htaccess file explained:

# Block direct access to scripts, text files and images folder
RewriteCond %{REQUEST_URI} ^/inc/menu\.php$ [OR]
RewriteCond %{REQUEST_URI} ^/inc/inmenu\.txt$ [OR]
RewriteCond %{REQUEST_URI} ^/admin/list\.php$ [OR]
RewriteCond %{REQUEST_URI} ^/([^/.]+)\.txt$ [OR]
RewriteCond %{REQUEST_URI} ^/comments/([^/.]+)\.txt$ [OR]
RewriteCond %{REQUEST_URI} ^/img/$
RewriteRule .* - [F]
#
# (1) Intercept and redirect requests that are not for the '/admin/' pages
#
# EXTERNAL REDIRECT 1 (LIMIT HOME PAGE TO SINGLE URL)
# If '/index.php' is at the END of the requested path, redirect to '/'
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
#
# EXTERNAL REDIRECT 2
# If request is 'GET /page.php HTTP/1.1' redirect to '/page'
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/.]+)\.php\ HTTP/
RewriteRule ^([^/.]+)\.php$ http://www.example.com/$1 [R=301,L]
#
# EXTERNAL REDIRECT 3 (ONLY FOR WEB ROOT)
# For websites beginning with www
# If request does not include www, redirect to URLs with www
# (reversible for non-www websites: redirect from with-www to without)
RewriteCond %{REQUEST_URI} !^/admin/
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# (2) Internal rewrites
#
# INTERNAL REWRITE 1 (home page)
# If request is '/' internal rewrite to '/index.php'
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ /index.php [L]
#
# INTERNAL REWRITE 2 (search page)
# If request is 'search?terms=anything' internal rewrite...
# to '/search.php?terms=anything'
RewriteCond %{REQUEST_URI} ^/search$
RewriteCond %{QUERY_STRING} ^terms=(.*)$
RewriteRule ^search(.*)$ /search.php?%1 [L]
#
# INTERNAL REWRITE 3 (other pages)
# If the request is 'GET /page HTTP/1.1' internal rewrite to '/page.php'
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/.]+)\ HTTP/
RewriteRule ^([^/.]+)$ /$1.php [L]

The .htaccess file (la.plume Micro CMS typical)

*From v7.5: if an .htaccess file exists, the lines shown green allow resubmission of setup to update the .htaccess file while preserving extra rules you may have added for other purposes, canonical domain etc.

# BEGIN la.plume
AddDefaultCharset UTF-8
ErrorDocument 404 /error404.php
<IfModule mod_rewrite.c>
RewriteEngine On
#
RewriteCond %{REQUEST_URI} ^/inc/menu\.php$ [OR]
RewriteCond %{REQUEST_URI} ^/inc/inmenu\.txt$ [OR]
RewriteCond %{REQUEST_URI} ^/admin/list\.php$ [OR]
RewriteCond %{REQUEST_URI} ^/([^/.]+)\.txt$ [OR]
RewriteCond %{REQUEST_URI} ^/comments/([^/.]+)\.txt$ [OR]
RewriteCond %{REQUEST_URI} ^/img/$
RewriteRule .* - [F]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/.]+)\.php\ HTTP/
RewriteRule ^([^/.]+)\.php$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{REQUEST_URI} !^/admin/
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ /index.php [L]
#
RewriteCond %{REQUEST_URI} ^/search$
RewriteCond %{QUERY_STRING} ^terms=(.*)$
RewriteRule ^search(.*)$ /search.php?%1 [L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/.]+)\ HTTP/
RewriteRule ^([^/.]+)$ /$1.php [L]
</IfModule>
# END la.plume

If the lines shown green (# BEGIN la.plume and # END la.plume) are manually deleted from the .htaccess file, resubmission of setup will create a completely new (default) .htaccess file.

If you write extra rules they should be placed before # BEGIN la.plume so they are preserved when setup is resubmitted.

Page last modified: December 04, 2014

Get the files (ZIP)

Downloads since
September 2011:

17,383