I'm doing my first steps with url-rewriting
and can't get the following to work:
In my application, a skin can be loaded by applying query parameter ?skin=some_id
to any page in the application. I want to change:
http://www.mysite.com/anypage.html?skin=123
into:
http://www.mysite.com/123/anypage.html
but I cannot get it to work.
This is what I currently have in my httpd.conf
:
<IfModule mod_rewrite.c>
RRewriteRule (.*)/(.*)?app=(.*)$ %1/%3/%2 [NC,R=301,L]
</IfModule>
Questions:
This isn't working, so I would like to know what I'm doing wrong?
Also with the URL in effect, what is the URL the user enters? http://www.mysite.com/123/anypage.html
which "maps" to http://www.mysite.com/anypage.html?skin=123
?
And if I want to access the query parameter, do I have to extract it from the actual url (?skin=...
) or from the rewritten URL?
Thanks for helping out!
EDIT:
So I have it sort of working doing it like this (helpful tester here):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} skin=(\w+)
RewriteRule ^.*\.html /%1? [R=301]
</IfModule>
This will redirect:
www.some.com/index.html?skin=xyz => www.some.com/xyz
Not quite there yet.