Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: regex help for mod_rewrite
04-14-2011, 06:00 PM #1
- Join Date
- Apr 2011
- Thanked 0 Times in 0 Posts
regex help for mod_rewrite
ok, first of all I would like to say I'm a regex IDIOT!. That being said, here's what I got:
RewriteRule ^/([^/\.]+)/deals/([^/\.]+)/?$ index.php?key=$1&permalink=$2
What I'm trying to do is match the following url request paths:
The string will always start with /
The string may or may not end with /
The "key-goes-here" part will always be alphanumeric and - (hyphens to separate words)
The "permalink-goes-here" part will always be alphanumeric and - (hyphens to separate words)
Thanks in advance
04-15-2011, 05:15 PM #2
- Join Date
- Jun 2008
- Redmond, WA
- Thanked 100 Times in 94 Posts
Try something like this:
I highly recommend you look into REGEX. I avoided it for the longest time but it, truthfully, saves a lot of time and effort while programming to match user input. I found the following two things to be very helpful resources:Code:^[A-Za-z0-9\-]+/deals/[A-Za-z0-9\-]+[/]?$
Hope this helps!
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com