Apache: Redirect domain to other domain with appen

2019-09-09 19:57发布

问题:

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?

回答1:

I believe it should be something close to this:

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