Tuesday, 15 June 2010

apache - RedirectMatch Equivalent of a Mod_Rewrite Rule for Rearranging Directory Structure -



apache - RedirectMatch Equivalent of a Mod_Rewrite Rule for Rearranging Directory Structure -

i want recreate mod_rewrite rule in form of redirectmatch directive.

first, please take @ mod_rewrite rule:

rewriteengine on rewritecond %{http_host} (www.)?africananimals.com rewritecond %{request_uri} zebras rewriterule ^(stripes|hooves)/zebras/?$ zebras/$1 [r,l]

the rule (written helpful , knowledgeable stackoverflow contributor) tells server transform these 4 urls:

http://africananimals.com/stripes/zebras

http://africananimals.com/hooves/zebras

http://www.africananimals.com/stripes/zebras

http://www.africananimals.com/hooves/zebras

-- these improve , more logically structured ones:

http://africananimals.com/zebras/stripes

http://africananimals.com/zebras/hooves

http://www.africananimals.com/zebras/stripes

http://www.africananimals.com/zebras/hooves

(these not actual urls, examples.)

there other websites on hosting server, may happen have identical directory structure, first conditional ensures rule applied africananimals.com domain, or without www.

the sec conditional ensures rule applied when word "zebras" nowadays in url.

the rule selects either "stripes" or "hooves" followed "/zebras" or "/zebras/" , rewrites url, placing selected item (either "stripes" or "hooves") after "zebras/" – exactly should done.

question: how can same task accomplished using redirectmatch directive?

being apache amateur, much appreciate insight professional.

i guess it:

redirectmatch 301 ^/(stripes|hooves)/zebras/?$ http://africananimals.com/zebras/$1

apache mod-rewrite url-rewriting rewrite

No comments:

Post a Comment