I want to setup a system so that multiple custom domains like [mydomain.com/params] will redirect to [myapp.com/mydomain.com/params]. Can I do this using only DNS s
Here's the solution:
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} (.*) [NC] RewriteRule (.*) http://myapp.com/%1/$1 [P,R=301,L]
%1 = the domain that is requested, so www.d1.com or d1.com
$1 = the rest of the URL that comes after the vanity URL (d1.com/everyting/else
This config invisibly redirects all requests.
Examples:
d1.com => returns content from => myapp.com/d1.com/ www.d1.com => returns content from => myapp.com/www.d1.com/ d1.com/blog/post/1 => returns content from => myapp.com/d1.com/post/1