Page 1 of 1

[solved] mod_rewrite not working!

Posted: Tue Mar 17, 2009 2:38 pm
by wolphy
I've done this successfully on two other websites and can't figure out what's going wrong here!  Can anyone help me?!

Details:

Hosting on Bluehost


CMS Version  1.5.3



config.php code

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

#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';


.htaccess code
Options +FollowSymLinks
RewriteEngine on
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 ^(.+).html$ index.php?page=$1 [QSA]
SetEnv TZ America/New_York

#option to remove directory listings in this folder
Options -Indexes

Re: mod_rewrite not working!

Posted: Tue Mar 17, 2009 7:46 pm
by wolphy
could there be something missing from my {metadata} tag?  The tag is in the template, so I know that part's okay.

Re: mod_rewrite not working!

Posted: Tue Mar 17, 2009 8:12 pm
by Ziggywigged
Try using the htaccess that come with the core download:

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>

Re: mod_rewrite not working!

Posted: Tue Mar 17, 2009 9:25 pm
by wolphy
I think that's what I originally started with.  Just tried it again and nope, that doesn't work either...

Re: mod_rewrite not working!

Posted: Tue Mar 17, 2009 9:47 pm
by Ziggywigged
Are you by any chance using Dreamweaver to upload the .htaccess file? If so, try using a different FTP program.

Re: mod_rewrite not working!

Posted: Tue Mar 17, 2009 10:55 pm
by wolphy
Nope, not uploading with Dreamweaver.  I'm using CPanel to upload htaccess.txt, then renaming to .htaccess

Re: mod_rewrite not working!

Posted: Tue Mar 17, 2009 11:40 pm
by wolphy
SOLVED!

okay,  hopefully NOBODY else suffers from the same kind of stupidity i've suffered from the last couple of days.

here's what happened:
i designed and wrote an entire site, THEN changed the config and htaccess files to implement pretty URLs and no matter what i did, i couldn't get it to work.  i fiddled endlessly with the code in the config and htaccess files, researched exhaustively, posted in forums, and just about gave up, thinking i had a quirky host or a nasty guardian angel.  the one thing i DIDN'T think of was that all the links in my html were written before the mod_rewrite rules so the hrefs were to php query strings.  oh man...... where's the "embarassed" emoticon?