[solved] Pretty URL not working

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
pukka
Forum Members
Forum Members
Posts: 119
Joined: Thu Nov 12, 2009 6:02 pm

[solved] Pretty URL not working

Post by pukka »

Hello,

I am trying to get my site to use pretty url. Below are my settings in the config.php file:

$config['url_rewriting'] = 'mod_rewrite';

$config['page_extension'] = '.html';

$config['use_hierarchy'] = false;

$config['query_var'] = '';


However the pages are still coming up as http://www.website.com/index.php?page=anotherpage


What am i doing wrong?

One of the installation manuals says to include a .htaccess file in the root of the website.

The full content of .htaccess file is:


# 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 ^(.+).htm$ index.php?page=$1 [QSA]


Obviously i have messed up somewhere.

Please help.


Thanks.

EDIT: please add [solved] to subject line when it is...
Last edited by Anonymous on Tue Dec 22, 2009 10:38 pm, edited 1 time in total.
Peace & Love

--------------------------------------------------------------------------
Useful stuff: {$entry->fields|@print_r}

web design london
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Pretty URL not working

Post by RonnyK »

try using the default htaccess.txt that exists in the /docs folder, rename that to .htaccess in the root.

Ronny
User avatar
pukka
Forum Members
Forum Members
Posts: 119
Joined: Thu Nov 12, 2009 6:02 pm

Re: Pretty URL not working

Post by pukka »

I did what you said however when i uploaded the .htaccess document to the root the website stops working and displays a "500 internal server error" message.


The contents of the htaccess file are:

-------------------------------------------
# Attempt to override some php settings, these settings may be helpful on some hosts if your
# default configuration does not meet CMS's minimum requirements, and your host
# has given your account appropriate permissions
#php_value upload_max_filesize "10M"
#php_value session_save_path "tmp/cache"

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# (this is important, so uncomment if your host permit)
#Options -Indexes
#ServerSignature Off
#
Options +FollowSymLinks
#

RewriteEngine on
#
#Sub-dir e.g: /cmsms
RewriteBase /

#
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
#RewriteCond %{REQUEST_URI} !/$
#RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
#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]

---------------------------------------------------------------------------------------------


What do i need to edit in the file to get it working?

Do i need to make any changes to the config.php file or is it ok as shown above?

Am i right in assuming that the current url's will be updated or will i have to manually change them?


Thanks in advance.
Peace & Love

--------------------------------------------------------------------------
Useful stuff: {$entry->fields|@print_r}

web design london
Ziggywigged
Power Poster
Power Poster
Posts: 424
Joined: Sat Feb 02, 2008 12:42 am

Re: Pretty URL not working

Post by Ziggywigged »

Are you hosted on a Windows server?
Take a penny, leave a penny.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Pretty URL not working

Post by Rolf »

Try to put # before the line  'options +follow...'
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Pretty URL not working

Post by Rolf »

and you need to put 'page' back in the config.php, in the line 'query_var', otherwise the .htaccess file can't do its job.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
pukka
Forum Members
Forum Members
Posts: 119
Joined: Thu Nov 12, 2009 6:02 pm

Re: Pretty URL not working

Post by pukka »

- To Ziggywigged: I am on a linux debian server  -


Rolf:
I put # before the line as you said and that has fixed the "500 internal server error" message issue.

Will the pages update by themselves or do i have to do something to activate the pretty url's.

I have also cleared the cache.

I have changed the config.php file and it looks like this now:


#------------
#URL Settings
#------------

#What type of URL rewriting should we be using for pretty URLs?  Valid options are:
#'none', 'internal', and 'mod_rewrite'.  'internal' will not work with IIS some CGI
#configurations. 'mod_rewrite' requires proper apache configuration, a valid
#.htaccess file and most likely {metadata} in your page templates.  For more
#information, see:
#http://wiki.cmsmadesimple.org/index.php ... ty_URL.27s
$config['url_rewriting'] = 'mod_rewrite';

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';

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

#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 is as follows:

----------------
# Attempt to override some php settings, these settings may be helpful on some hosts if your
# default configuration does not meet CMS's minimum requirements, and your host
# has given your account appropriate permissions
#php_value upload_max_filesize "10M"
#php_value session_save_path "tmp/cache"

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# (this is important, so uncomment if your host permit)
#Options -Indexes
#ServerSignature Off
#
#Options +FollowSymLinks
#

RewriteEngine on
#
#Sub-dir e.g: /cmsms
RewriteBase /

#
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
#RewriteCond %{REQUEST_URI} !/$
#RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
#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]




It's still not working.

What am i doing wrong?
Peace & Love

--------------------------------------------------------------------------
Useful stuff: {$entry->fields|@print_r}

web design london
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: Pretty URL not working

Post by Jos »

pukka wrote: However the pages are still coming up as http://www.website.com/index.php?page=anotherpage

What am i doing wrong?
How did you create those links? Are they manually put there, or are the links created by the menumanager {menu} tag?
Last edited by Jos on Sat Dec 19, 2009 11:20 pm, edited 1 time in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Pretty URL not working

Post by Rolf »

should be okay now... do you have hardcoded url's on your site perhaps? got an url of the site?
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
pukka
Forum Members
Forum Members
Posts: 119
Joined: Thu Nov 12, 2009 6:02 pm

Re: Pretty URL not working

Post by pukka »

It works ok now.


Thanks a lot guys. Very much appreciated. ;D
Peace & Love

--------------------------------------------------------------------------
Useful stuff: {$entry->fields|@print_r}

web design london
Post Reply

Return to “CMSMS Core”