Apache mod_rewrite, "[0-9]" VS "\d"

  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post October 24th, 2009, 5:13 pm

I've traced a malfunctioning RewriteRule going from one server to another server, back to the use of "\d" in a RewriteRule vs using "[0-9]" in the RewriteRule.

Anyone familiar with which version of Apache, mod_rewrite, OS, etc the use of "\d" began being available in RewriteRule ?
Why yes, yes I am.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 24th, 2009, 5:13 pm

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 7349
  • Loc: Seattle, WA
  • Status: Offline

Post October 29th, 2009, 10:56 am

I don't think \d is valid for any mod_rewrite rules. That works fine for regexes with PHP and PERL, but Apache mod_rewrite is much more limited and I always write \d as 0-9 and \w as a-zA-Z(and any other characters wanted here such as _).
Ozzu Hosting - Want your website on a fast server like Ozzu?
Contact US for more information about our plans and rates
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post October 29th, 2009, 11:16 am

It works on my box here at home. Actually I just looked and it works on an Ozzu hosting server too. :)

PHP Code: [ Download ] [ Select ]
<?php
echo $_GET['a'];
?>
  1. <?php
  2. echo $_GET['a'];
  3. ?>


APACHE Code: [ Download ] [ Select ]
RewriteEngine on
RewriteBase /temp/
 
RewriteRule ^(\d)\.html$ index.php?a=$1 [L]
 
  1. RewriteEngine on
  2. RewriteBase /temp/
  3.  
  4. RewriteRule ^(\d)\.html$ index.php?a=$1 [L]
  5.  


The only major differences I can tell between the Ozzu server, my home server, and the old server, is that the old server is running a 1.3.x version of Apache whereas the others are on some branch of 2.x.x

I'm thinking one of the 2.x.x branches of Apaches mod_rewrite introduced better support for PCRE. All I can find at apache.org is a note about it using PCRE, but it doesn't go into detail about "how" supported it is and I'm not finding anything about when it started.
Why yes, yes I am.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 7349
  • Loc: Seattle, WA
  • Status: Offline

Post October 29th, 2009, 11:20 am

Ahh that may be the case. I never did look into seeing if they improved support with the 2.x.x branch. That is good to know though.
Ozzu Hosting - Want your website on a fast server like Ozzu?
Contact US for more information about our plans and rates
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post October 29th, 2009, 11:24 am

Alright I found a changelog with something good. :D

http://httpd.apache.org/docs/2.2/new_features_2_0.html

Quote:
Regular Expression Library Updated
Apache 2.0 includes the Perl Compatible Regular Expression Library (PCRE). All regular expression evaluation now uses the more powerful Perl 5 syntax.
Why yes, yes I am.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 38 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.