It’s not plug and play configure Osclass or any other service to work with multiple subdomains. There are three steps:
- DNS Wildcard
- Apache Wildcard
- Osclass subdomain configuration
First of all you need to let know to the whole internet which IP resolve any of your subdomains. So, region.example.net will resolve the same IP as region2.example.net.
In the examples I will use as your IP server 127.0.0.1 and as a domain example.net. You should replace this values for your IP and domain. Furthermore, I’m not sure if the following solutions varies depending the DNS Manager you use but here I put two examples:
*.example.net. A 127.0.0.1
As you can see the value you have to change is the A record. Finally, if you have another subdomain pointing to another IP, you should just specify it before the *.
Once you’ve done this, it could take up to 24 or 72 hours to take
I’m not sure how it can be done in each specific hosting service, so I would explain what you have to specify in the VirtualHost configuration.
<VirtualHost *:80> ServerName example.net ServerAlias *.example.net CustomLog /var/log/apache2/example.net_access_log combined ErrorLog /var/log/apache2/example.net_error_log <Directory /var/www/example.net/web> Options -Indexes FollowSymLinks -MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
What we’re saying with this configuration is that all the petitions that come to any subdomain of example.net will go to the folder where Osclass is installed.
Changes in config.php
In order to accept any subdomain, Osclass’ config.php have to be modified, the line that contain the WEB_PATH have to be changed to
Cookies have to be set to accept all subdomains as only one website, change your php.ini file, search for the line
and change it to
session.cookies_domain = .domain.tld
Note: From Osclass 3.3 and newer versions, if you’re not able to modify your server’s configuration files, you could define COOKIE_DOMAIN in the config.php
Note: It’s important to have a “.” (dot) before the domain. Do not include “www” or anything else.
Osclass subdomain configuration
Now we have to specify which type of subdomain we want: categories, countries, regions or cities. You can change this configuration in your oc-admin > Settings > Advanced.
Let me know if you have problems with your configuration in the comments of this post.