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

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • 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 ?
Strong with this one, the sudo is.
  • 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: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Online

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?
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • 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: [ Select ]
<?php
echo $_GET['a'];
?>
  1. <?php
  2. echo $_GET['a'];
  3. ?>


APACHE Code: [ 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.
Strong with this one, the sudo is.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Online

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?
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • 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.
Strong with this one, the sudo is.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 26 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.