Pretty URLs mod_rewrite htaccess not working [solved]

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
howey
Forum Members
Forum Members
Posts: 158
Joined: Fri Sep 14, 2007 1:05 pm

Pretty URLs mod_rewrite htaccess not working [solved]

Post by howey »

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

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';
The htaccess file as:

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
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.
Last edited by howey on Tue Jul 22, 2008 9:32 pm, edited 1 time in total.
Pierre M.

Re: Pretty URLs mod_rewrite htaccess not working

Post by Pierre M. »

Hello,
howey wrote: My problem is I don't know if there is a problem with the "code" or the server configuration.
There is no failure description in your report.
howey wrote: 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.
The files seem OK after a quick review.

Pierre M.
howey
Forum Members
Forum Members
Posts: 158
Joined: Fri Sep 14, 2007 1:05 pm

Re: Pretty URLs mod_rewrite htaccess not working

Post by howey »

Thanks Pierre – at least I know where to look now.

Cheers
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Pretty URLs mod_rewrite htaccess not working [solved]

Post by kermit »

howey wrote: 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.
your web server logs (access and/or error) should clue you in to any server config issues.

what OS (and control panel, if any) are used inside the VPS? that may help someone point you in the right direction to find apache's config files.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Locked

Return to “[locked] Installation, Setup and Upgrade”