Search code examples
apachehttp-redirectapache-config

Apache: Redirect domain to other domain with appended querystring


I want example.se to redirect to example.com?lang=swe

It works fine with this apache config:

<VirtualHost *:80>
    ServerName example.se
    ServerAlias *.example.se
    Redirect permanent / http://example.com/?lang=swe
</VirtualHost>

The problem is that this breaks if there is something else after the domain, ex: example.se/page1 should redirect to example.com/page1?lang=1 but with the setup above it redirects to example.com?lang=swepage1.

Is there a way to do this right?


Solution

  • I believe it should be something close to this:

    RedirectMatch permanent ^/(.+)$ http://example.com/$1?lang=swe