Link to home
Start Free TrialLog in
Avatar of fellz
fellz

asked on

htaccess: reorder variables in clean-urls using RewriteRule

Hi,
Currently our URLs look like that:

http://mydomain.com/site2009/pages/welcome.php?sid=de|1000|317|f10.0.22|1921680156521|welcome

We want to use clean-urls - the solution should be made using htaccess so that the URLs look like that:
http://mydomain.com/de/welcome/1000/317/1921680156521/f10.0.22

Many thanks in advance!
Avatar of ravenpl
ravenpl
Flag of Poland image

You need to use http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritemap with external rewriting program.
Avatar of fellz
fellz

ASKER

Thanks for the hint. However - what I'm looking for is the complete solution (htaccess-code) to paste it and go.
RewriteCond %{REQUEST_URI} /site2009/pages/welcome.php
RewriteRule ^.*welcome.php\?sid=([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)\|(.*) /$1/welcome/$2/$3/$5/$4
ahoffmann, the rule should go the other way i suppose. And I assume the number of variables(the length of url) is variable - that's why suggested external rewrite map.
Avatar of fellz

ASKER

yes, ravenpl is right:
entering the following in the browser
http://mydomain.com/de/welcome/1000/317/1921680156521/f10.0.22

should call
http://mydomain.com/site2009/pages/welcome.php?sid=de|1000|317|f10.0.22|1921680156521|welcome
behind the scenes
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fellz

ASKER

many thanks for the solution, ravenpl!
there's just one more question: is there a chance to make it work when the number of variables is not constant but at least limited to a maximum of say 10 variables?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fellz

ASKER

great! many thanks!