interactivetools.com
Quickstart Guide...
How to Install
How to Upgrade
How to Move Servers
How to Private Label
Restore Hacked Sites
Admin Menu
General Settings
Private Labeling
User Accounts
Section Editor (List)
Add New Editor
Section Editor (Edit)
Field Editor
Text Field
Text Box
Wysiwyg
Date/Time
List
Checkbox
Upload
Separator
Regional Settings
Code Generator
Show Code
Viewers
Viewer Options
Displaying Uploads
Search Engines
Advanced Topics
In-Depth Getting Started Guide
Working With Generated Code Guide
Using SlideShowPro With CMS Builder
Special Fieldnames
Changing and Removing File Extensions
Demo Mode

View Changelog »
Glossary
Need Help? Questions?
Post in forum »

Changing and Removing File Extensions

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 ".php" Files
This method outlines how you can use PHP code on files created with the ".php" extension. Create a plain text file called ".htaccess", and add the following line to it:


Addhandler application/x-httpd-php .php .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 ".php" 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 ".php" 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 ^(.*)\.php$ $1.php [nc]
Once you've uploaded this file to the root directory of your web server, if someone visits a page called "home.php", 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.
Copyright © 1999-2016 interactivetools.com, inc.