mod rewrite troubles [solved, by me!]

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

mod rewrite troubles [solved, by me!]

Post 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.
Last edited by s.dot on Thu Jun 28, 2007 1:34 am, edited 1 time in total.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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. :?:
Post Reply