Htaccess for dynamic php CMS pages

Posted: September 5, 2012 in PHP

Options -MultiViews
DirectoryIndex index.php
RewriteEngine On

# base path of your project
RewriteBase /myproject/cmswebsite/

# if filename have .php extension i.e. demo.php then you can access it using http://localhost/myproject/cmswebsite/demo
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]

# For dynamic CMS pages
# http://localhost/myproject/cmswebsite/index.php?pageLink=about-us can be accessed by http://localhost/myproject/cmswebsite/about-us
RewriteCond %{REQUEST_URI} !/admin
RewriteCond %{REQUEST_URI} !/js
RewriteCond %{REQUEST_URI} !/images
RewriteCond %{REQUEST_URI} !/upload
RewriteCond %{REQUEST_URI} !^/(.*).php
RewriteRule ^([^/]+)/?$ index.php?pageLink=$1&%{QUERY_STRING} [L] # ONE_LANGUAGE is true

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s