regex - .htaccess instead a range use 2 options -


i have code in .htaccess file:

options +symlinksifownermatch rewriteengine on    # turn on rewriting engine  rewriterule    ^([a-z]+)/([a-z]+)?$    index.php?lang=$1&loc=$2    [nc,l]  rewriterule    ^([a-z]+)/([a-z]+)/restaurants/?$    all_rest.php?lang=$1&loc=$2    [nc,l] 

as can see, variables lang , loc can in range ([a-z]+) dont need total range need words: en or chin lang variable , hk or kw loc variable.

i have tried this:

rewriterule    ^([en][chin])/([hk][kw])/restaurants/?$    all_rest.php?lang=$1&loc=$2    [nc,l] 

but dont know why works hk kw y no para en chin.

any idea?

you using character sets, match individual characters. so, [hk][kw] match these: hk, hw, kk, kw. want this:

rewriterule ^(en|chin)/(hk|kw)/?$ index.php?lang=$1&loc=$2 [nc,l] rewriterule ^(en|chin)/(hk|kw)/restaurants/?$ all_rest.php?lang=$1&loc=$2 [nc,l] 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -