htaccess rules for Perch CMS

December 23, 2015, 10:36 pm
Author: James Griffiths

Perch CMS makes content management for small business clients a cinch.

The following htaccess rules help you get Perch CMS to load your website without interfering with accessing the admin console...

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/perch
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^\.]+)$ $1.php [NC,L]	
</IfModule>

Be sure to place the above into a .htaccess file in the root of your public_html directory.

The above rules accomplish the following:

  • If not the perch directory proceed to next rule
  • If the requested address isn't a real file then redirect to the matching PHP file
  • If the requested address isn't a directory then redirect to the matching PHP file
  • Remove the .php extension for 'clean' URL's

The NC and L flags at the end of the final rule:

RewriteRule ^([^\.]+)$ $1.php [NC,L]	

Accomplish the following:

  • NC (No Case) - When matching the URL request don't use case sensitivity (I.e. no difference between A-Z or a-z)
  • L (Last) - Stop the rewriting process at this line and don't apply any more rewriting rules

Categories

« Return to Posts

Post a comment

All comments are welcome and the rules are simple - be nice and do NOT engage in trolling, spamming, abusiveness or illegal behaviour. If you fail to observe these rules you will be permanently banned from being able to comment.