Page 1 of 1

mod rewrite troubles [solved, by me!]

Posted: Thu Jun 28, 2007 1:05 am
by s.dot
.... I seem to have these a lot.

The following .htaccess file worked when developing locally, then I moved it to a CentOS linux server, and the rewrite rules I have don't work. A simple rewrite rule WILL work, so I know the .htacess file is being read and evaluated.

Code: Select all

Options -Indexes

RewriteEngine On
RewriteRule ^graphics/([\d]+)/.+/index.html$ /graphics.php?cat_id=$1
RewriteRule ^.+graphics/img/([\d]+_.+)$ /load-image.php?img=$1

ErrorDocument 404 /404.php
A sample URL for the first rewrite rule would look like this:
http://www.example.com/graphics/12/computers/index.html

And a sample URL for the second one would look like this
http://www.example.com/computer-graphic ... onitor.gif

When trying the above URLs, I get sent to the 404.php page.

Posted: Thu Jun 28, 2007 1:33 am
by s.dot
Odd. It seems the .htaccess file didn't like [\d]. When changing both occurences of those to [0-9], it works.

Code: Select all

Options -Indexes

RewriteEngine On
RewriteRule ^graphics/([0-9]{1,2})/.+/index.html$ /graphics.php?cat_id=$1
RewriteRule ^.+graphics/img/([0-9]+_.+)$ /load-image.php?img=$1

ErrorDocument 404 /404.php
Me thinks I was mixing up the two different styles of regexes. :?: