Is there any way of doing a mod_rewrite from one domain to another, but keeping the browser URL the same throughout? This is what I want:
User enters something like bacon.com and ends up on example.com/bacon, but the browser URL always stays as bacon.com?
I basically want to do a mod_rewrite whilst masking the URL. Sorry for the unimaginative example domains, but it's still only 10am... I've checked lots of other answers, but they always usually involve mod_rewrites on the same domain. They don't deal with the fact that bacon.com is already a ServerAlias of example.com.
I can give you three ways of doing this.
1 Using virtual hosts
Given that bacon.com is a ServerAlias for example.com, i.e. they're both on the same server, you can do this without using any mod_rewrite at all. Think of it this way: mod_rewrite is at its most basic a way to map URLs to a file system. So what I would do is to simply set up a separate VirtualHost that uses the correct directory as its base.
Here's a brief example:
As you see, this isn't a rewrite; instead you're setting bacon.com up to use the base directory of example.com/bacon as its own DocumentRoot.
2 Using mod_rewrite as a proxy
If you do want to use mod_rewrite instead, you can have it use the P flag which will make mod_rewrite act as a proxy. Here's an example:
Edit in answer to the comment:
Since you want the http://bacon.com/css to be http://example.com/css instead of http://example.com/bacon/css, make a separate rule that goes first and catches that specific URL:
In order to do this, you need to have mod_proxy loaded and enabled. Do however note that this will reduce performance compared to using mod_proxy directly, as it doesn't handle persistent connections or connection pooling. So if you can't do what you want with VirtualHosts, I'd suggest the third method:
3 Using mod_proxy directly
For more information about that, see the mod_proxy documentation