Pretty URLs mod_rewrite htaccess not working [solved]
Posted: Tue Jul 22, 2008 1:16 pm
Hi, as a complete newbie I am working my way through CMS MS and have managed to work most things out (eventually). However, I am trying to implement pretty URLs using mod_rewrite.
My config file is as attached
The htaccess file as:
My problem is I don't know if there is a problem with the "code" or the server configuration. I cleared the cash on the admin section, still no joy.
I am working on a Mac using the WebFusion VPS solution, so I have found it virtually impossible to get at the root config files to know if the "AllowOverride All" directive is allowed etc.
If the above config and htaccess are correct, then it may be the server. In which case I'll probably abandon ship and leave it as it is.
My config file is as attached
Code: Select all
#------------
#URL Settings
#------------
#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;
#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';
#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism? This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;
#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy? (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;
#If using none of the above options, what should we be using for the query string
#variable? (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';
Code: Select all
RewriteEngine On
#option to remove directory listings in all folder (avoid publishing unwanted contents)
Options -Indexes
# Deny access to config.php
# This can be useful if php ever breaks or dies
# Use with caution, this may break other functions of CMSms that use a config.php
# file. This may also break other programs you have running under your CMSms
# install that use config.php. You may need to add another .htaccess file to those
# directories to specifically allow config.php.
# <Files "config.php">
# order allow,deny
# deny from all
# </Files>
# URL Filtering helps stop some hack attempts
#IF the URI contains a "http:"
RewriteCond %{QUERY_STRING} http\: [OR]
#OR if the URI contains a "["
RewriteCond %{QUERY_STRING} \[ [OR]
#OR if the URI contains a "]"
RewriteCond %{QUERY_STRING} \] [OR]
#OR if the URI contains a "<__script__>"
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
#OR if the script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR if any script is trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR if the URI contains UNION
RewriteCond %{QUERY_STRING} UNION [OR]
#OR if the URI contains a double slash
RewriteCond %{QUERY_STRING} // [OR]
#OR if the URI contains a *
RewriteCond %{QUERY_STRING} \*
#then deny the request (403)
RewriteRule ^.*$ - [F,L]
# End URL Filtering
# CMSMS Rewriting
# Set assume mod_rewrite to true in config.php and clear CMSMS cache
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# END CMSMS
# END Rewrite rules
# No sense advertising what we are running
ServerSignature Off
# HTTP response header forced to be "Server: Apache" only
# Sometimes this istruction must be saved inside httpd.conf or apache.conf or sites-enabled instead of .htaccess
ServerTokens Prod
I am working on a Mac using the WebFusion VPS solution, so I have found it virtually impossible to get at the root config files to know if the "AllowOverride All" directive is allowed etc.
If the above config and htaccess are correct, then it may be the server. In which case I'll probably abandon ship and leave it as it is.