: Is there any way to use a sub-domain as your root domain I have been asked by my supervisor to look for a way to make the website's root domain access the sub-domain instead. Like: example.com
I have been asked by my supervisor to look for a way to make the website's root domain access the sub-domain instead.
Like:
example.com is the root domain
test.example.com is the sub domain
Typing example.com should proceed instead to the test.example.com. Is this possible?
More posts by @Moriarity557
2 Comments
Sorted by latest first Latest Oldest Best
Alternatively if you run NGINX (you can't do .htaccess) create a server block for example.com
Have simply
server {
listen 80;
server_name example.com example.com;
rewrite ^ $scheme://example.example.com;
}
server {
listen 80;
server_name example.example.com;
### REST OF VHOST ###
}
Indeed you can. For instance some do not realize a url is an actual sub-domain. So it is happening all the time.
You can go to your server settings and choose your sub-domain as the main domain name or add some code to create a redirect.
Many people use Apache servers for hosting websites and when you have used a domain name with traffic to it, a good idea is to use a 301 redirect in the .htaccess file located in the root folder of your website. The purpose is you are telling search engines, bookmarks etc, that hey we are the same and we moved here. That's the short version.
You would add some code like this to the htaccess file.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ subdomain.example.com/ [L,R=301,NC]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.