Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Redirect Subdomain Without Changing URL

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
2 posts • Page 1 of 1
vebinua
Posts: 3
Joined: Fri Apr 03, 2020 8:36 am

Os: CentOS 6x
Web: apache + nginx
Redirect Subdomain Without Changing URL
  • Quote

Post by vebinua » Fri Apr 03, 2020 8:42 am

Hey Guys,

I hope this finds you all well. I have a primary domain domain.com created and I wanted a subdirectory sub.domain.com created too. As suggested, I simply need to treat it as another web domain so I created one for sub.domain.com.

I, however, wanted sub.domain.com to point to a directory/folder on my primary domain domain.com like the following:
sub.domain.com ---> domain.com/sub

where sub is simply a folder/directory, and that the URL stays the same sub.domain.com (not changing to domain.com/sub)

Is this possible via .htaccess? how do I go about this?

My machine runs on Centos 7 (with apache2 + Nginx). Thank you!
Top

plutocrat
Posts: 232
Joined: Fri Jan 27, 2017 9:16 am

Os: Ubuntu 17x
Web: apache + nginx
Re: Redirect Subdomain Without Changing URL
  • Quote

Post by plutocrat » Thu Apr 09, 2020 1:21 am

I'm supposing you have your reasons for doing this, rather than just moving the files into the subdomain public_html directory ...

Two ways of doing it that I can think of.

a) Remove subdomain public_html directory, and symlink it to the other place. eg.
ls ~/web/
domain.com
sub.domain.com
cd sub.domain.com
mv public_html public_old # might need sudo?
ln -s /home/admin/web/domain.com/public_html/directory/ ./public_html/

b) Create a new template for your subdomain site based on one of the vesta default templates. Edit the path within that to point to the correct directory. Save the template with a different name (mysubdomain.tpl / stpl). Select that template for your sub.domain.com from the vestacp interface. I can't be more specific with this one as I don't know what your set up is. Search the forum for guides.
Top


Post Reply
  • Print view

2 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password