on-internet
← Community

.htaccess redirect + rewrite: Prefix uri with language code while keeping initial uri

Stack Overflow ·

I am trying to rewrite/redirect incoming requests so that they will always be prefixed by a language code but would like to keep the originally requested path: example.org/de/ -> rewrite to example.org?lang=de example.org -> redirect to example.org/de/ which will then be rewritten to example.org?lang=de example.org/en/ -> rewrite to example.org?lang=en example.org/foo/bar -> redirect to example.org/de/foo/bar which will then be rewritten to example.org/foo/bar?lang=de These were my thoughts on this: RewriteBase / # No 'lang' key in query string RewriteCond %{QUERY_STRING} !lang=(en|de) # AND r

Comments

Sign in or sign up to comment and upvote.

No comments yet.