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

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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 ?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9102
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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 _).
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9102
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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.

Post Information

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

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.