url - How to mod_rewrite a query parameter to a path folder name? -
i'm doing first steps url-rewriting
, can't following work:
in application, skin can loaded applying query parameter ?skin=some_id
page in application. want change:
http://www.mysite.com/anypage.html?skin=123
into:
http://www.mysite.com/123/anypage.html
but cannot work.
this have in httpd.conf
:
<ifmodule mod_rewrite.c> rrewriterule (.*)/(.*)?app=(.*)$ %1/%3/%2 [nc,r=301,l] </ifmodule>
questions:
isn't working, know i'm doing wrong?
also url in effect, url user enters? http://www.mysite.com/123/anypage.html
"maps" http://www.mysite.com/anypage.html?skin=123
?
and if want access query parameter, have extract actual url (?skin=...
) or rewritten url?
thanks helping out!
edit:
have sort of working doing (helpful tester here):
<ifmodule mod_rewrite.c> rewriteengine on rewritecond %{query_string} skin=(\w+) rewriterule ^.*\.html /%1? [r=301] </ifmodule>
this redirect:
www.some.com/index.html?skin=xyz => www.some.com/xyz
not quite there yet.
i'd recommend going skinning application differently. way have create duplicate content issues search engines because see same content each page on site every skin have.
that say, yoursite.com/dark/about.html
identical content yoursite.com/spring/about.html
search engines may have hard time deciding version use. in addition, seems create work linking other pages on site since have create links programmatically use proper path , skin.
i have url activating skin , store preference in cookie or in session , skin site based on cookie/session value , maintain 1 set of urls.
unless want skin in url, shy away using url or query string indicate skin use. instead have preference attached account or stored in cookie.
Comments
Post a Comment