Mailing List Archive

Need Help with Regular Expression Rule
I want urls like these:

mydomain.com/books/1234

mydomain.com/books/1234/567

to be internally redirected to:

mydomain.com/books/books.php?p=1234

mydomain.com/books/books.php?p=1234&v=567


I have tried a rule like this:
RegX: ^/books/(.*)
Substitution: /books/books.php?p=$1

But I get 404 errors.

Any help will be appreciated.


--
Stephen Aiena
stephen@mathtv.com
805-550-2586
_______________________________________________
Cherokee mailing list
Cherokee@lists.octality.com
http://lists.octality.com/listinfo/cherokee
Re: Need Help with Regular Expression Rule [ In reply to ]
The following rules should work for this. Add a new handler for it (or just
change the "default" handler to "Redirection") and use the following:

Type: Internal
Regular Expression: ^/books/(\d+)/(\d+)$
Substitution: /books/books.php?p=$1&v=$2

Type: Internal
Regex: ^/books/(\d+)$
Substitution: /books/books.php?p=$1

This assumes that both parameters will always be numeric (\d is any digit).
The issue you may encounter with using "/books/(.*)" is that .* matches
anything, including "index.php". This *may* cause weird things to happen
(but I'm not too sure)

Hope this helps!

- Daniel


On Tue, Nov 29, 2011 at 5:23 AM, Stephen Aiena <stephen@mathtv.com> wrote:

> I want urls like these:
>
> mydomain.com/books/1234
>
> mydomain.com/books/1234/567
>
> to be internally redirected to:
>
> mydomain.com/books/books.php?p=1234
>
> mydomain.com/books/books.php?p=1234&v=567
>
>
> I have tried a rule like this:
> RegX: ^/books/(.*)
> Substitution: /books/books.php?p=$1
>
> But I get 404 errors.
>
> Any help will be appreciated.
>
>
> --
> Stephen Aiena
> stephen@mathtv.com
> 805-550-2586
> _______________________________________________
> Cherokee mailing list
> Cherokee@lists.octality.com
> http://lists.octality.com/listinfo/cherokee
>