Is it possible to display the contents of a website domain to a subdirectory using .htaccess or the DNS zone file?
For example, I need to display the contents of 123.123.123.123 at mydomain.com/blog. Is there any way to do this?
The usual way to do this is to create a DNS A record blog.example.com pointing to the IP Address, then have a HTTP redirect to send it to the subdirectory.
You would need to create a virtual host on your server to host the file for the redirect
Related
I would like to set up my web app to use the "www" subdomain as my primary url. I'll be using a service to handle 301 redirects from my naked/apex domain to my subdomain (example.com -> www.example.com). What is the correct DNS record type for my "www" subdomain? Cant seem to find a clear answer on this.
An "A" record pointing to my websites IP address?
A "CNAME" pointing to my naked/apex domain?
It's CNAME. A record is pointing to the webserver IP address. CNAME will serve as an alias. Commonly when example.com and www.example.com points to the same application and hosted by the same server. To avoid maintaining two different records, it's a best practice to create an A record for example.com pointing to the server IP address and a CNAME record for www.example.com pointing to example.com
I publish my project to GitLab Pages and add my custom domain. Now I want to redirect the default GitLab url username.gitlab.io/project to my domain name mydomain.com. I add two records in DNS as below:
www.mydomain.com CNAME mydomian.com
www.mydomain.com CNAME username.gitlab.io/project
but it dosen’t work. How should I do?
If you look at an url, for example: http://example.net/foo/bar the domain name is only the example.net part.
DNS only controls domain names, so you will not be able to use CNAME records to point to subdirectories on the target domain.
To do something like that, you would need a webserver which proxies requests to that directory. (Search for nginx reverse-proxy for some examples)
I have setup a wordpress website on Digital Ocean. I have domain registered on GoDaddy. I have created domain from Digital Ocean and mapped the name-servers to GoDaddy. But when I enter the url, it just redirects to the IP and IP is shown on address bar instead of domain name.
Is there anything else should I add?
Assuming that You are using DNS servers provided by DigitalOcean and mapped your droplet's IP to your domain, You need to add the following Name Servers in Your GoDaddy Configuration:
ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com
If it is still Redirecting to Your IP address then make sure in Your Apache/Nginx Vhost Block, there is no redirect defined in them.
Also, you are running Wordpress then it is possible that you had set up your site's URL as IP address, it might be the reason for redirect, if it is then make sure to change it from wp-config.php
You can find more info here: https://codex.wordpress.org/Changing_The_Site_URL
Hope this Helps!
I created a subdomain sub.domain.com. then I issued a certificate forit. NOw, I want to add a Cname to map a URL address Lms-traffic.manager.net. to the full FQDN of my subdomain.
HOw should I proceed?
A DNS CNAME is an ALIAS for a domain name. A way to set the ip address depending on another name to get its. it does not do redirects.
the URL record is for a redirect , but will not pass any parameters, just the domain name.
You can do a redirect at the host server... httpd.conf file or .htaccess
for example. apache... SEE
https://httpd.apache.org/docs/2.4/rewrite/remapping.html
I suggest doing the redirect at the web server host, because you have a lot more control of what to pass, and where it goes to. and could do it in the .htaccess file.
Everytime I try to create a subdomain with this combo, it simply says the page doesn't exist. I have the subdomain directory created, so I'm not sure what I'm doing wrong. for example if I want
subdomain.domain.com, then
domain.com/subdomain will work, but
subdomain.domain.com won't work.
Any insight?
Firstly you will need a DNS record for you subdomain. This can be a CNAME record if you just want the the subdomain to be an alias of the main domain (Canonical Name). If you want the subdomain to be hosted on a different IP address or server then you need a new A record.
From the sounds of it you want a CNAME record for your subdomain created in your DNS manager, and then you want to configure your web server to look at the host headers to map to the sub directory you created. How you go about this depends on the type of web server.