Page 1 of 1

[solved] mod_rewrite pretty URLs not working

Posted: Thu Aug 13, 2009 10:57 pm
by ntmr
A common problem, maybe, but I've got it in any case.  ;D

So, I'm running a XAMPP package plus CMS Made Simple: CMSms 1.6.3, PHP 5.2.9, MySQL 5.0.51a  (I think that's the version), and Apache 2.2.11.

My .htaccess for CMSms reads like this, taken from \doc\htaccess.txt:

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 /
#
# 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>
I have an AllowOverride All directive set in httpd.conf for the directory:

Code: Select all

<Directory "c:/nathaniel/cmsmadesimple">
    AllowOverride All
I was getting 404s on content pages and Forbiddens all around (including admin area) using some different code that had been suggested elsewhere. With the current .htaccess, I get redirected to the server doc root, which a XAMPP .htaccess redirects to /xampp (which is supposed to happen).

And I know for sure mod_rewrite is on because I have checked it in httpd.conf before and it gets loaded and I've gotten WordPress pretty URLs working with this same server and this code in httpd.conf:

Code: Select all

<Directory "c:/nathaniel/wordpress">
	Options FollowSymLinks
	AllowOverride FileInfo
Anyway, that's sightly irrelevant, but my point is that I think mod_rewrite itself is working.

Any ideas on getting this working?

Edit: Not to mention, I've got config.php configured:

Code: Select all

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

Code: Select all

$config['assume_mod_rewrite'] = true;
#$config['internal_pretty_urls'] = false;

Re: mod_rewrite pretty URLs not working

Posted: Fri Aug 14, 2009 10:22 pm
by ntmr
'Scuse me, but... BUMP!  ;D

Re: mod_rewrite pretty URLs not working

Posted: Sat Aug 15, 2009 7:54 am
by alby
ntmr wrote:
#Sub-dir e.g: /cmsms
RewriteBase /
I have an AllowOverride All directive set in httpd.conf for the directory:

Code: Select all

<Directory "c:/nathaniel/cmsmadesimple">
    AllowOverride All
Are you sure that is right or is /cmsmadesimple?

ntmr wrote:

Code: Select all

$config['assume_mod_rewrite'] = true;
#$config['internal_pretty_urls'] = false;
Drop there rows (pre 1.6)

Alby

Re: mod_rewrite pretty URLs not working

Posted: Sat Aug 22, 2009 11:33 pm
by ntmr
alby wrote:
Are you sure that is right or is /cmsmadesimple?
Yeah, I think I had it right, since that's where I have CMS Made Simple running. I just changed it to /nathaniel/cmsmadesimple, though, since I have the alias /nathaniel set up for c:/nathaniel, for convenience.
alby wrote:
ntmr wrote:

Code: Select all

$config['assume_mod_rewrite'] = true;
#$config['internal_pretty_urls'] = false;
Drop there rows (pre 1.6)

Alby
Done.

So, neither of the changes made a difference. I'm still getting redirected to the server root if I try to access any of the pages besides my default page.

Edit: By the way, I am clearning my CMSms cache after I change some config.php settings, so that one is ruled out.

Re: mod_rewrite pretty URLs not working

Posted: Tue Sep 15, 2009 11:58 pm
by ntmr
BTW, I never did solve this locally, but I bet I could have got it to work, because once it was online I did get it to work. I believe the key issue was missing metadata - I forgot to put it in one of my templates (have two - one for pages and one for front page) and added it later on. Anyway, I tried it with the online version using the .htaccess code here and bam! it worked.