Random thoughts & observations

From the mundane to the profound and everything in between here’s what’s rocking our world

htaccess rules for Perch CMS

Posted: December 23, 2015
Written by: Saints At Play
Category: Perch CMS

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
« Return to Posts

Comments

There are no comments

Posting comments after three months has been disabled.