Page 1 of 2
Pretty URL's SOLVED
Posted: Thu Apr 01, 2010 10:57 pm
by electrifire
Im struggling here with the pretty url's, in the config file I have this code:
#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'] = '.php';
#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';
And this have made my url's have the extension .php but the page does not exist, where have I gone wrong, each page now has the correct extension such as electrical.php but I get the error.
http://www.electrifire.co.uk/test
Re: Pretty URL's
Posted: Fri Apr 02, 2010 12:00 am
by Peciura
IMO you have misconfigured "/.htaccess". simply because site is in subdirectory. You edit it like this (i guess)
RewriteRule ^test/(.+)\.php$ index.php?page=$1 [QSA]
Re: Pretty URL's
Posted: Fri Apr 02, 2010 4:57 am
by replytomk3
Even simpler,
RewriteBase /yourfolder
I just answered this question yesterday somewhere else.
Re: Pretty URL's
Posted: Fri Apr 02, 2010 6:12 am
by Dr.CSS
I believe it is actually RewriteBase /yourfolder w/o the / at the end...
From default htaccess file...
#Sub-dir e.g: /cmsms
RewriteBase /
Re: Pretty URL's
Posted: Fri Apr 02, 2010 7:49 pm
by electrifire
Dr.CSS I'm afraid your post went over my head:
I didn't actually edit the .htaccess file I just edited the config file, the site is in a sub domain currently until I get it up and running properly on cmsms.
So I need to edit .htaccess file with RewriteBase /test?
Re: Pretty URL's
Posted: Fri Apr 02, 2010 9:16 pm
by Dr.CSS
Yes...
Re: Pretty URL's
Posted: Sat Apr 03, 2010 9:44 am
by electrifire
Ok it works as in the url is something like
http://www.electrifire.co.uk/test/electrical.php
however I get this error form google when I click a link from the menu:
Oops! This link appears to be broken.
This is the contents of my .htaccess file:
SetEnv DEFAULT_PHP_VERSION 5
RewriteBase /test
Any other ideas?
Re: Pretty URL's
Posted: Sat Apr 03, 2010 4:26 pm
by replytomk3
Re: Pretty URL's
Posted: Sat Apr 03, 2010 5:59 pm
by electrifire
hmmm please explain then as the fact the url has shortened and now has the .php extension made me think the mod rewrite was kind of working and the issue I had was the page is not actually at this new extension
Re: Pretty URL's
Posted: Sat Apr 03, 2010 6:07 pm
by replytomk3
Post your config.php URL section and complete .htaccess here again. Is this Linux hosting?
Re: Pretty URL's
Posted: Sat Apr 03, 2010 6:22 pm
by electrifire
Yes this is linux hosting and the sit is in a sub domain until I have everything up and running then I will replace my current site with cms.
This is the URL settings:
#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'] = '.php';
#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';
This is the contents of my .htaccess file:
SetEnv DEFAULT_PHP_VERSION 5
RewriteBase /test
Re: Pretty URL's
Posted: Sat Apr 03, 2010 6:33 pm
by replytomk3
LOL
your htaccess should be
Code: Select all
SetEnv DEFAULT_PHP_VERSION 5
ServerSignature Off
# 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>
<IfModule mod_rewrite.c>
RewriteEngine on
#
#Sub-dir e.g: /cmsms/
RewriteBase /test
# 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
# 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]
</IfModule>
optional settings for security below SetEnv DEFAULT_PHP_VERSION 5:
Code: Select all
Options +FollowSymLinks
Options -Indexes
Re: Pretty URL's
Posted: Sat Apr 03, 2010 6:35 pm
by electrifire
hmmm should that code be in there to start with or should I have added it manually?
Thanks for the tip
Re: Pretty URL's
Posted: Sat Apr 03, 2010 6:36 pm
by replytomk3
for mod_rewrite to work, you must have all of that in your .htaccess
you must add it manually
read documentation next time. It will save everyone's time. Most importantly, yours.
Re: Pretty URL's SOLVED
Posted: Sun Apr 04, 2010 4:19 pm
by maxxbu
I have the same problem, and try all these things but it won't work. I get every time the "Not Found" Page.
CMSms is in the sub dir "cmsms"
.htaccess File
Code: Select all
# 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
#
<IfModule mod_rewrite.c>
RewriteEngine on
#
#Sub-dir e.g: /cmsms
RewriteBase /cmsms
#
# 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]
</IfModule>
config.php
Code: Select all
#------------
#URL Settings
#------------
$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';
I have also tried your file, but even with this configuration the "Not Found" page appears
other information
mod_rewrite is enabled
.htaccess and config.php is readable
CMSms Version 1.7
The PHP Version is 5.2.10, recommend ist 5.2.12 but I don't think there is the problem...