1

I have spent days researching the internet and I can not find the answer.

I have abc.com website i got sub domain address with the help of .htaccess but How can i show different theme according to subdomain.

Explanation. User create sub domain flower.abc.com and vegetable.abc.com etc i get user selected theme the according to sub domain from database php but i can not know how can i change root link and root directory

directory

/index.php  
     //theme folder   
flower/index.php   
....../css/  
...../js/

vegetable/index.php  
....../css/   
...../js/  
etc more theme available

but when user vegetable.abc.com select theme vegetable then show theme vegetable when user select flower theme then show flower theme.

vegetable.abc.com/vegetable/index.php  
to   
vegetable.abc.com/index.php
  • Maybe this can help. See Mass Virtual Hosting section in this [answer](https://stackoverflow.com/a/586160/4903314) – Umair Khan Sep 05 '20 at 08:20

1 Answers1

0

you can use .htaccess

vegetable.abc.com/vegetable/index.php   

to

vegetable.abc.com/index.php

Rule in .httaccess file

RewriteEngine On

RewriteCond %{HTTP_HOST} ^vegetable\.abc\.com\/vegetable\/index\.php [NC]
RewriteRule ^$ https://vegetable.abc.com/index.php [R=302,L]

virtual host

<VirtualHost *:80>
    ServerAlias *.example.com
    VirtualDocumentRoot /var/www/%1/
</VirtualHost>
Balaji
  • 9,657
  • 5
  • 47
  • 47
  • if I adopt this method we need to enter all theme name .htaccess file If the company grow more than Thousands theme it's not a good technique – Sanaullah Sajid Mukhtiar Sep 05 '20 at 09:26
  • i think you need to configure in virtual host becuase you are dynamicy binding each domain has seperate file – Balaji Sep 05 '20 at 09:38
  • i already using wildcard domain my project but my case is little bit different , i used same source for unlimeted wildcard domain eg: abc.name.com it looks a abc page ,123.name.com page looks like 123 page but i have used single source file ,eg :wix.com – Balaji Sep 05 '20 at 09:41