By osman103
Hi,
I have the domain custom.com which I am trying to point to site.example.com which in turn points to example.com/site.
I currently have this in my Virtual Host:
ServerAlias *
VirtualDocumentRoot /var/www/html/%1
I have tried creating a CNAME record for custom.com which points to site.example.com, however for some reason it points to the root site example.com.
How could I allow users to directly point custom domains to subdomains of my site? What would have to be done to my Virtual Host/which records would be required?
Subdomains actually work as intended to since they point to the directories containing the same name. However, any custom domains pointed to any subdomain just points to the root site rather than pointing to the subdomain.
I would appreciate any help with this.
Thank you!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You are kind of on the right track as you do want the DNS for custom.com and site.example.com to point to the same host which is example.com. However DNS (CNAME) does not take the URI into consideration. This is why custom.com ends up being directed to example.com and not example.com/site.
To accomplish what you are looking for is to add some rewrite rule that change your custom.com domain to either site.example.com or to custom.com/site
Some reference material to get you started https://httpd.apache.org/docs/2.4/rewrite/remapping.html
Be careful and take into consideration on mapping your domains to not create redirect loops or to many redirects.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.