0

I have tried using Mod Rewrite via .htaccess to solve this issue to no avail.

So I will ask if it can be accomplished via Vhosts.

This is CentOS7 using Apache.

I have a domain, call it mydomain.com. It is sitting in (docroot)

Users are created dynamically within a folder of (docroot) called Users. So for example, user 'xxx' would sit in the folder (docroot)/Users/xxx, and user 'yyy' would sit in (docroot)/yyy , and so it goes...

What I am trying to do, so far to no avail, is to find a way to direct subdomain traffic to xxx.mydomain.com and serve the contents of (docroot)/Users/xxx , or yyy.mydomain.com serves (docroot)/Users/yyy etc, etc.

Where in comparison, if I direct traffic to mydomain.com simply to (docroot)

So mydomain.com points to /var/www/html and xxx.mydomain.com should point to /var/www/html/Users/xxx

The problem is if I use .htaccess it wants to change xxx.mydomain.com to mydomain.com/Users/subdomain. This is not what I am looking for.

It needs to retain the xxx.mydomain.com , so no rewriting of the url , while serving the appropriate directory, which is /var/www/html/Users/xxx

Any help would be appreciated. Any clarification can be given

I have tried modifying the .htaccess file to no end

So far I have tried this as my conf file but to no end.

<VirtualHost *:80>

ServerName dev.mydomain.com
ServerAlias dev.mydomain.com
DocumentRoot /var/www/html/mydocroot

</VirtualHost>

<VirtualHost *.80>

ServerAlias *.dev.mydomain.com
VirtualDocumentRoot /var/www/html/mydocroot/Users/%0

</VirtualHost>

I am very curious as to what I am doing wrong

  • Possible duplicate of [Virtualhost For Wildcard Subdomain and Static Subdomain](https://stackoverflow.com/questions/758351/virtualhost-for-wildcard-subdomain-and-static-subdomain) – misorude Aug 13 '19 at 07:19
  • Check this answer in particular, https://stackoverflow.com/a/48893687/10283047 – I think you should be using `%1` there, not `%0` – misorude Aug 13 '19 at 07:20
  • I solved my own question . But thank you it did help – seleifheit3 Aug 13 '19 at 07:23

1 Answers1

1

I have solved my own question. For anyone out there who would like to know :

<VirtualHost *:80>

    ServerName dev.mydomain.com
    ServerAlias dev.mydomain.com
    DocumentRoot /var/www/html/docroot

</VirtualHost>

<VirtualHost *:80>

ServerAlias *.dev.mydomain.com
VirtualDocumentRoot /var/www/html/docroot/Users/%1

</VirtualHost>