mod rewrite - mod_rewrite: transform = and & in slashes -


i looking solution transform =,?,& found in query string simple slash /. more specific, link like:

http://www.mydomain.com/product.php?c=1&sc=12&products_id=15

and this: http://www.mydomain.com/product.php/c/1/sc/12/products_id/15

whatever master page (in case product.php, foo.php, bar.php...or else). have googled lot didn't find solution achieve i'm looking for. have found complex rewrite rules, include "page name" them: i.e.

rewriterule ^/?index/([^/]+)/([^/]+)$ /index.php?foo=$1&bar=$2 [l,qsa]

that rule applicable index.php , known variables foo, bar. need more general one, whatever master page is, whatever variables are. can done?

any suggestion? thanks

i assume you're using apache >= 2.2. add apache conf:

<ifmodule mod_rewrite.c>     rewriteengine on      # absolutely need use rewritebase if snippet in .htaccess     # if .htaccess file located in subdirectory, use     # rewritebase /path/to/subdir     rewritebase /      rewritecond %{query_string} ^(=|&)*([^=&]+)(=|&)?(.*?)=*$     rewriterule ^(.*)$ $1/%2?%4= [n,ne]      rewritecond %{query_string} ^=$     rewriterule ^(.*)$ $1?  [r,l] </ifmodule> 

the first rewritecond/rewriterule pair repeatedly matches token delimited & or = , adds path. important flag [n] causes whole ruleset start on again, rule matches. additionally, = appended end of query string. create mark in url @ least 1 rewrite has happened.

the second ruleset checks = mark remains after url has been rewritten , issues redirect.

have @ http://wiki.apache.org/httpd/rewritequerystring useful hints.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -