Page 1 of 1

[solved] Pretty URL not working

Posted: Sat Dec 19, 2009 6:24 pm
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...

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 6:34 pm
by RonnyK
try using the default htaccess.txt that exists in the /docs folder, rename that to .htaccess in the root.

Ronny

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 8:43 pm
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.

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 8:47 pm
by Ziggywigged
Are you hosted on a Windows server?

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 10:35 pm
by Rolf
Try to put # before the line  'options +follow...'

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 10:53 pm
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.

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 11:04 pm
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?

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 11:18 pm
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?

Re: Pretty URL not working

Posted: Sat Dec 19, 2009 11:25 pm
by Rolf
should be okay now... do you have hardcoded url's on your site perhaps? got an url of the site?

Re: Pretty URL not working

Posted: Sun Dec 20, 2009 12:06 am
by pukka
It works ok now.


Thanks a lot guys. Very much appreciated. ;D