View previous topic :: View next topic |
Author |
Message |
logikal -
Joined: 20 Apr 2002 Posts: 19
|
Posted: Sun Jan 21, 2007 9:15 pm Post subject: RegEx string error |
|
|
Hey Aprelium,
Thanks for finally invoking the url-rewrite feature. It's awesome! I have one question about a regular expression I'm attempting to use:
The following expression isn't quite working, and I'm wondering what I'm doing wrong.
If someone types /wiki/page_name, then they should be redirected to /_home/index.php?page=wiki&name=page_name or, equally, /_home/index.php?page=wiki&name=page_name&do=&id=.
If someone types /wiki/page_name/edit, then they should be redirected to /_home/index.php?page=wiki&name=page_name&do=edit.
Code: | ^/wiki([^/].*){0,3}$ |
internally redirect:
Code: | /_home/index.php?page=wiki&name=$1&do=$2&id=$3 |
Any ideas as to what's causing this to break? My guess is that it's something about the regex not liking [^/]... |
|
Back to top |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Mon Jan 22, 2007 2:27 am Post subject: |
|
|
I would suggest logging the URL rewriting. This will give you many clues as to why it might not be working right. See http://localhost:9999/hosts/host@0/edit/urlrewrite/advanced/edit.
Put this rule in first:
Redirect to Code: | /_home/index.php?page=wiki&name=$1&do=edit | Be sure to set 'Next Action' to 'Stop matching'.
Put this rule in second:
Redirect to Code: | /_home/index.php?page=wiki&name=page_name |
As to why your code didn't work, the problem is in the brackets. It's treating the caret (^) as a literal value, not the identifier that is translated "begins with".
/wiki^/the_page_name would match with your RegEx. _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
|
logikal -
Joined: 20 Apr 2002 Posts: 19
|
Posted: Mon Jan 22, 2007 3:14 am Post subject: |
|
|
Thanks, Stephen... I'll give it a try :wink: |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Jan 22, 2007 2:00 pm Post subject: Re: RegEx string error |
|
|
logikal,
The problem is that your Regular expression defines only a single backreference $1 (there is only a single pair of brackets). $2 and $3 will always be empty.
If our guess is right, you'll have to change the regular expression to;
Code: | ^/wiki(/([^/]*)(/([^/]*)(/([^/]*))?)?)?$ |
The rediret to value should also be updated to:
Code: | /_home/index.php?page=wiki&name=$2&do=$4&id=$6 |
By the way, tunring URL rewriting debugging/log on and testing your regex on http://www.regextester.com/ could help a lot when creating new rules. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
logikal -
Joined: 20 Apr 2002 Posts: 19
|
Posted: Tue Jan 23, 2007 1:07 am Post subject: |
|
|
Ah, that makes total sense. I was assuming regex allowed "looping" of sorts...
Hey man, I thought I'd say congratulations. I've stuck with Abyss since the beginning, and it's good to see that you're finally starting to get the recognition you deserve. Abyss is a rare gem, and it's cool to see that it's still freely available to anyone. Unlike most software, Abyss only gets better over time.
-Matt |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Tue Jan 23, 2007 2:56 pm Post subject: |
|
|
logikal,
Thanks for your compliments. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
|