I wish to setup something to ensure that multiple custom domain names like [mydomain.com/params] will redirect to [myapp.com/mydomain.com/params]. Can One do that using only DNS configurations?
I am speculating that's difficult, so will it be a much better means to fix direct mydomain1.com, mydomain2.com, mydomain3.com, etc. to 1 Ip then use Mod_Rewrite to direct each request (invisibly) to myapp.com/mydomain#.com/params ? Each rerouted URL results in content that's loaded from the centrally located Content management systems.
Any suggestions, assets, and/or solutions could be greatly appreciated!
No, you cannot only use DNS for your.
If every domain can run stand alone (world wide web.domain.com) this is an easy multi-site setup and doesn't require mod_rewrite, just a lot of
<virtualHost> directives that could indicat each site.
If you want precisely the setup you describe (http://world wide web.hostname.com/world wide web.2ndhostname.com/directoryname) you'd need one
<VirtualHost> with the domain names as aliases, along with a mod_rewrite based redirect to suggest incoming demands right directory.
Here's the answer:
- Set DNS Address records for those vanity domain names towards the same Ip (so d1.com, d2.com, d3.com, etc. all have DNS A records set to 1 IP or FQDN for instance)
- Setup the server with one VirtualHost while using IP because the domain
- Within that VirtualHost's root directory, produce a .htaccess that creates the mod_rewrite
- Make use of the following for that mod_rewrite within the .htaccess:
Options +FollowSymLinks RewriteEngine On RewriteCond % (.*) [NC] RewriteRule (.*) http://myapp.com/%1/$1 [P,R=301,L]
%1 = the domain that's asked for, so world wide web.d1.com or d1.com
$1 = the relaxation from the URL which comes following the vanity URL (d1.com/**everyting/else**
This config invisibly redirects all demands.
d1.com => returns content from => myapp.com/d1.com/ world wide web.d1.com => returns content from => myapp.com/world wide web.d1.com/ d1.com/blog/publish/1 => returns content from => myapp.com/d1.com/publish/1