Current location: Hot Scripts Forums » Other Discussions » Web Servers » regex - word too short in pattern?


regex - word too short in pattern?

Reply
  #1 (permalink)  
Old 05-10-08, 10:46 AM
clickzilla clickzilla is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
regex - word too short in pattern?

Hi,

I'm building a tagging system for a site of mine and encountered a problem with a rule for rewriting URLs, using mod_rewrite.

The rule I was using was
Code:
RewriteRule ^tag/([^/]+)/$ tag.php?t=$1
but it just didn't work at all ... the $1 was replaced with nothing "";

So (after hours of searching ) I've changed the rule to
Code:
RewriteRule ^tags/([^/]+)/$ tag.php?t=$1
and it works.

The difference between those two is tiny ( from "^tag/..." to "^tags/..");

Could someone explain to me why did this happen?
Why using 3-letter-short (or less) words in the pattern screws everything up?

Btw... have a great weekend!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-10-08, 10:53 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
I can't reproduce the error. Both of your codes work for me (locally tested). And as far as I'm concerned, there's no minimum character limit. Are you sure you didn't change anything else?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-10-08, 11:51 AM
clickzilla clickzilla is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, I'm positive.

I've tested this on localhost only. Will give it a try when I finish the whole thing.

Maybe another rewrite rule interferes with this.

Perhaps this one?
Code:
RewriteRule ^(.*)/(.*)-example_(.*).html$ example.php?e=$3
Thanks for taking the time to test and reply!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-10-08, 11:54 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
It's quite possible that some of your rewritings conflict, but I don't think the one above causes any problems. But try changing the order of some similar ones.

Can you post your whole .htaccess file? That'd make it a bit easier.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 05-10-08, 12:03 PM
clickzilla clickzilla is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
There's no other similar rule.

All other rules look something like

Code:
RewriteRule ^index.html$ index.php
or like this
Code:
RewriteRule ^login.html(.*)$ login.php$1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP variables to microsoft word Deansatch PHP 7 12-17-07 03:21 PM
multi value hashtable minority ASP.NET 1 03-01-06 09:37 AM
SMS (Shared Short Code / keyword) vagabondos Job Offers & Assistance 0 11-04-05 10:01 PM
Telephone Word Generator necro_mancer C/C++ 4 09-07-05 05:01 PM
Find the beginning letter of a word mcrob PHP 6 05-23-05 11:06 AM


All times are GMT -5. The time now is 09:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.