Score:0

Apache - Redirect while dropping everything after domain

mx flag

So I can do a simple redirect on an Apache virtual host like this:

<VirtualHost *:443>
        ServerName www.old-domain.com
        Redirect / www.new-domain.com/new-resource

</VirtualHost>

But of course, if I go to www.old-domain.com/old-resource it redirects to www.new-domain.com/new-resourceold-resource. I'd like to just drop everything after the old domain name, regardless of the directory or file, so www.old-domain.com/whatever/doesntmatter/foo.html still just redirects to www.new-domain.com/new-resource.

How do I accomplish that?

Score:0
mx flag

Okay, with a bit more searching it found this question, and it's a pretty simple solution:

<VirtualHost *:443>
        ServerName www.old-domain.com
        RewriteEngine on
        RewriteRule ^/?.+$ www.new-domain.com [L,R]
</VirtualHost>
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.