Pretty URL problem

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
devilslayer
Forum Members
Forum Members
Posts: 41
Joined: Sat Apr 23, 2005 11:38 pm

Pretty URL problem

Post by devilslayer »

Hello CMSMS's

I have installed CMS Made Simple on a website and would like to enable pretty URLS.

I have read numerous posts and the FAQ located at:

http://wiki.cmsmadesimple.org/index.php ... retty_URLs

Whenever I try I get an internal server error.

I have tried using the default .htaccess file provided in the docs folder of the installation and the example in the pretty URLS Wiki Page.  The extracts are below:

config.php
#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'] = '/';

#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'] = true;

#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';
.htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteRule ^(.+)(.html)?$ index.php?page=$1 [QSA]

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Because I still want rss to work I have added the following to the .htaccess file:
RewriteRule ^(.+)(.html)?$ index.php?page=$1 [QSA]
I have also tried the installation with this line removed.

I have managed to enable pretty URLs using the internal mechanism below, but would like to remove the index.php from the URL string
$config['internal_pretty_urls'] = true;
Thank You For your Help
alby

Re: Pretty URL problem

Post by alby »

devilslayer wrote: Because I still want rss to work I have added the following to the .htaccess file:
RewriteRule ^(.+)(.html)?$ index.php?page=$1 [QSA]
No, this is for .html page extension ...
Search in forum for News/rss rewrite ...

devilslayer wrote: I have managed to enable pretty URLs using the internal mechanism below, but would like to remove the index.php from the URL string
You cannot in internal pretty url

Alby
devilslayer
Forum Members
Forum Members
Posts: 41
Joined: Sat Apr 23, 2005 11:38 pm

Re: Pretty URL problem

Post by devilslayer »

Alby thanks for your help, but you seem to have misunderstood me.

I wanted to enable Pretty URLs using mod_rewrite however I couldn't get this to work. I kept getting a server error when I tried mod rewite therefore I used the internal mechanism to give me the following:

http://www.mydomain.org.uk/index.php/contact-us

This is ok for now, but I still would like to use mod_rewrite and a .htaccess file to enable pretty URLS  in the form of

http://www.mydomain.org.uk/contact-us

or

http://www.mydomain.org.uk/contact-us/dave

What do I need to put in my .htaccess file and config.php file to enable Pretty URLS using mod_rewrite and a .htaccess file?

Many Thanks for your help.
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Pretty URL problem

Post by Coldman »

Hi!
Try this .htaccess

Code: Select all

# BEGIN Optional settings

# Turns off directory browsing
# not absolutely essential, but keeps people from snooping around without 
# needing empty index.html files everywhere
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>

# Sets your 403 error document
# not absolutely essential to have, 
# or you may already have error pages defined elsewhere
ErrorDocument 403 /forbidden403.shtml

# No sense advertising what we are running
ServerSignature Off

# END Optional Settings

# BEGIN CMSMS and Rewrite Rules
# Make sure you have Options FollowSymLinks
# and Allow on

RewriteEngine On

# Might be needed in a subdirectory
#RewriteBase /

# 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 script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) 
RewriteRule ^.*$ - [F,L] 
# END 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
and in config.php change to this..

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'] = '/';

#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';
EDIT:
You can also read about pretty url here http://wiki.cmsmadesimple.org/index.php ... l_Settings
.htaccess is copied from that page...
Last edited by Coldman on Fri Aug 22, 2008 5:43 pm, edited 1 time in total.
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Pretty URL problem

Post by Dr.CSS »

Coldman wrote: #Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';
No matter what you do this will most likely give you an error, because most browsers etc. will think you are trying to open a folder, the URL will look like so...

www.mydomain.org.uk/contact-us/  where contact-us is supposed to be a file but is set as a folder...

I would highly recommend against this as it will ruin your chances of getting any SEO type links, as google or any search bot is going to think it needs to find a folder and try and look in it with no luck...
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Pretty URL problem

Post by Coldman »

mark wrote:
Coldman wrote: #Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';
I would highly recommend against this as it will ruin your chances of getting any SEO type links, as google or any search bot is going to think it needs to find a folder and try and look in it with no luck...
Yes you have right about SEO type links.
I copied that part from one of my test site on localhost and didn't see that added an "/"
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
Locked

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