USING CMSB WITH .HTML EXTENSIONS OR WITHOUT .PHP EXTENSIONS - Aug 4th, 2010


This one’s in the on-line CMSB documentation at

http://www.interactivetools.com/docs/cmsbuilder/file_extensions.html

but you may have missed it.

This page outlines techniques that you can use to render CMS Builder's PHP code on your pages without having to use the
".php" file extension, or to remove the file extension from your pages entirely. The methods described here require that
your site is hosted on an Apache server (most Linux hosting plans use Apache).

RENDERING PHP CODE ON ".HTML" FILES
This method outlines how you can use PHP code on files created with the ".html" extension.

Create a plain text file called ".htaccess", and add the following line to it:



Addhandler application/x-httpd-php .html .php



Now upload this file to the root web directory on your server. You should now be able to use CMS Builder's code on any
page with the ".html" or ".php" extensions. You can even add your own custom extensions to the code above if you'd like,
such as ".shtml" or ".htm". This method is ideal for situations where you need to use CMS Builder on a site that
currently uses static HTML pages, but would like to preserve the site's existing URL's.

USING MOD_REWRITE TO CHANGE THE FILE EXTENSION
This method will redirect any link that uses the ".html" extension to the corresponding file with the ".php" extension.
The URL in the visitor's address bar will not display ".php", so this process is entirely transparent. To do this,
create a plain text file called ".htaccess" and add the following code to it:



RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [nc]



Once you've uploaded this file to the root directory of your web server, if someone visits a page called "home.html",
the server will show the page using the code from the "home.php" file on your server.

USING MOD_REWRITE TO REMOVE THE FILE EXTENSION
This method will remove the ".php" file extension from all of your pages, so that you can use an URL like
www.yoursite.com/news instead of yoursite.com/news.php. Create a plain text file called ".htaccess", and add the
following code to it:



RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]



Once this file has been uploaded to the root directory on your web server, the ".php" extension will no longer be
required in your URL's to access pages.



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service