I am a real newbie regarding mod_rewrite so do not laugh. I'm by using this tool for testing: http://civilolydnad.se/projects/rewriterule/

Essentially I wish to rewrite

http://hostname/spanish/whatever/

into

http://hostname/whatever/?lang=es

Here's the very best I possibly could develop:

RewriteRule ^spanish/(.*)$ $1?lang=es [QSA,L,NC]

which appears to operate except once the asked for page already has parameters. For the reason that situation

http://hostname/spanish/gallery/photos/?page=2

will get rewritten as

http://hostname/spanish/gallery/photos/?page=2?lang=es

Can anybody help this confused newbie? Thanks greatly.

Something similar to this ought to help.

# Remove query strings from URL
RewriteCond %{THE_REQUEST} ^GET\ /.*\;.*\ HTTP/
RewriteCond %{QUERY_STRING} !^$
RewriteRule .* http://yourdomain.com%{REQUEST_URI}? [R=301,L]

Essentially, the tool is misleading, since the rule was shown to be correct, as written, when utilized on a genuine server atmosphere. Because of all.