Page 1 of 1

[Solved] Pretty URLs working, but pages not found

Posted: Tue Apr 22, 2008 9:27 pm
by gbrose85
Running with CentOS5/Apache/mod_rewrite on a local server.

Converted a static site to CMSMS and got everything working, menus, page css, etc.  Just had the standard ugly URLs to fix. 

Followed http://wiki.cmsmadesimple.org/index.php ... retty_URLs and now have pretty URLs -- if I hover over the menu, then the status line shows the correct pretty URLs.  If I click on a menu element, the correct pretty URL shows in the address line.

The only problem is that if I click on any menu element other than Home, I get a page not found.  The new cms-based site is visible at www.certiv.com.  The original static site is at www.certiv.net.

Any hint as to what I did wrong/suggestion of what still needs fixing would be very much appreciated.

.htaccess:

# 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 +FollowSymLinks

# 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.

order allow,deny
deny from all


# 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 ""
RewriteCond %{QUERY_STRING} (\|%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 [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# END CMSMS

# END Rewrite rules

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

Re: Pretty URLs working, but pages not found

Posted: Tue Apr 22, 2008 9:34 pm
by Nullig
Shouldn't your rewrite be:

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

Re: Pretty URLs working, but pages not found

Posted: Wed Apr 23, 2008 5:21 am
by gbrose85
Probably should be, but did not *directly* fix the problem that I was having.

It did, however, provide the clue that my .htaccess was not being read at all.

Long story short, I had my AllowOverride in the wrong place.  This is what made it all work:

Code: Select all

<VirtualHost xxx.xxx.xxx.xxx>
..
<Directory /path/to/doc/root/>
    AllowOverride All
</Directory>
...
</VirtualHost>
Thanks very much!

Re: [Solved] Pretty URLs working, but pages not found

Posted: Wed Apr 23, 2008 6:14 pm
by Pierre M.
Hello,

for further reference here is the guide for pretty URLs :
http://wiki.cmsmadesimple.org/index.php ... l_Settings
the FAQ may not be OK currently.

Pierre M.