Forum Moderators: phranque

Message Too Old, No Replies

complex mod-rewrite please assist!

hyphen and special character support

         

Summit

12:27 pm on Apr 11, 2008 (gmt 0)

10+ Year Member



Hi, In advance already thank you for your time!

I have the following problem. Rewriterule:
RewriteRule
^([A-Za-z\ ]*)-
([A-Za-z\ ]*)-
([A-Za-z\ ]*)-
([A-Za-z\ ]*)-
(best) ./display_all_category_list_city.php?group=city&catname=$1&idbycity=$4&type=$5

This works for this url:
http://www.example.com/Var1-Var2-Var3-Var4-best

But doesn't work with this sort of url's:
http://www.example.com/Var1-Var-2-Var3-Var4-best
http://www.example.com/Var1-Var2-Var-3-Var4-best
http://www.example.com/Var1-Var2-Var3-Var-4-best

What do I need to change on the rewriterule to get the url's with a hyphen inside a variable also correctly be displayed?
I have the same issue with special characters.
What do I need to change on the rewriterule to get the url's with a special characters inside a variable also correctly be displayed?

Thanks a lot in advance for your reply!

greetings,
Martijn

jdMorgan

1:16 pm on Apr 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To avoid ambiguity, you need to change the hyphens used between variables to a different character from the hyphens used inside variables. Otherwise, you won't be able to resolve this problem. You cannot use the same character as a variable-demarcation token and a variable-value at the same time. Consider using an underscore for one or the other.

Jim

Summit

9:21 pm on Apr 13, 2008 (gmt 0)

10+ Year Member



Hi, Thanks for your answer I will do this. Will the slash "/" also work?
And do you also know how to use special characters like e-with-umlaut?

Greetings,
Martijn

Summit

4:24 pm on Apr 30, 2008 (gmt 0)

10+ Year Member



Hi,
I have decided to keep the "-". The following rewriterules work fine for this:
RewriteRule ^(land)-([A-Za-z0-9\x00-\x7f\ ]*)$ _links_country.php?grp_name=$1&cat_name=$2
RewriteRule ^(land)-([A-Za-z0-9\x00-\x7f\ ]*)-n([0-9])$ _links_country.php?grp_name=$1&cat_name=$2&next=$3
RewriteRule ^(land)-([A-Za-z0-9\x00-\x7f\ ]*)-p([0-9])$ _links_country.php?grp_name=$1&cat_name=$2&prev=$3

RewriteRule ^(provincie)-([A-Za-z0-9\x00-\x7f\ ]*)$ _links_province.php?grp_name=$1&cat_name=$2
RewriteRule ^(provincie)-([A-Za-z0-9\x00-\x7f\ ]*)-of-([A-Za-z0-9\x00-\x7f\ ]*)$ _links_province.php?grp_name=$1&cat_name=$2&country=$3
RewriteRule ^(provincie)-([A-Za-z0-9\x00-\x7f\ ]*)-n([0-9])$ _links_province.php?grp_name=$1&cat_name=$2&next=$3
RewriteRule ^(provincie)-([A-Za-z0-9\x00-\x7f\ ]*)-p([0-9])$ _links_province.php?grp_name=$1&cat_name=$2&prev=$3

RewriteRule ^(plaats)-([A-Za-z0-9\x00-\x7f\ ]*)$ _links_city.php?grp_name=$1&cat_name=$2
RewriteRule ^(plaats)-([A-Za-z0-9\x00-\x7f\ ]*)-([A-Za-z0-9\x00-\x7f\ ]*)-n([0-9])$ _links_city.php?grp_name=$3&cat_name=$2&next=$4
RewriteRule ^(plaats)-([A-Za-z0-9\x00-\x7f\ ]*)-([A-Za-z0-9\x00-\x7f\ ]*)-p([0-9])$ _links_city.php?grp_name=$3&cat_name=$2&prev=$4

These rules work great for almost all my url's. Except for url's with strange characters like: Løkken-informatie

The rewriterule is used in the code with utf8_decode($_GET['cat_name']);
This works fine for almost all codes, except for the urls with a ø like Løkken-informatie
Does anybody have a solution fot this please?
Thanks in advance for your reply!
Greetings,
Martijn

TheMadScientist

4:38 pm on May 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Never mind, misread... duh.

[edited by: TheMadScientist at 4:40 pm (utc) on May 8, 2008]