I have a server with Plesk 10.4 on CentOS6, which has an interface for creating aliases of a domain, but not aliases of a subdomain.
For example I have this subdomain set up:
test.my-domain.co.uk
And then I want to create aliases so that the following subdomains map to the same root:
alias-1.my-domain.co.uk
alias-2.my-domain.co.uk
alias-3.my-domain.co.uk
I've tried creating a vhost.conf file like this:
<Directory /var/www/vhosts/my-domain.co.uk/subdomains/test>
# aliases
ServerAlias alias-1.my-domain.co.uk
ServerAlias alias-2.my-domain.co.uk
ServerAlias alias-3.my-domain.co.uk
</Directory>
And then reconfiguring all domains:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
However that fails.
Is this possible? Am I doing something wrong?
I suggest to
copy files and related data of subdomain to somewhere
delete subdomain
create add-on domain test.my-domain.co.uk
Now you should have ability to create aliases for test.my-domain.co.uk.
[update]
You are able create subdomain test.my-domain.co.uk and add-on domain test.my-domain.co.uk.
The difference in fact that for add-on domain you will have ability to create domain aliases.
Related
I have two wordpress sites running on two digitialocean droplets.
They both have ssl certificates and redirects all requests to https.
Let's call the first adresse https://my-freenom-domain-1.ml
Let's call the second adresse https://my-freenom-domain-2.ml
I have a domain registered on route53. Let's call the domain my-domain.com.
I'm trying to map (not redirect) all requests from https://my-domain.com to https://my-freenom-domain-1.ml
and all request from https://subdomain.my-domain.com to https://my-freenom-domain-2.ml
How would you do this?
Update:
What I've tried (That didn't work)
Creating a simple CNAME.
CNAME for main domain (my-domain.com):
Cannot create a CNAME for main domain and gives the following error:
RRSet of type CNAME with DNS name my-domain.com. is not permitted at apex in zone my-domain.com.
CNAME for subdomain (subdomain.my-domain.com):
I am able to create a CNAME for the subdomain, but requests are redirected.
So when I go to subdomain.my-domain.com I'm redirected to https://my-freenom-domain-2.ml
Create a S3 "redirect-bucket"
I've tried creating a S3 bucket that redirects all requests for the subdomain.
So bucket named subdomain.my-domain.com, redirects all redirects to https://my-freenom-domain-2.ml (https).
I then created a CNAME for subdomain.my-domain.com pointing to subdomain.my-domain.com.s3-website-eu-west-1.amazonaws.com.
But all requests are still redirected...
You need to create a virtual host for your new domain on your Digital Ocean droplets for it to work.
So I would do following to make it work -
Create virtual host for the new domain on the webserver of droplets,
or add the new domain as server in the webserver config.
Add the SSL certificates of the new domain to the old webserver or alternatively terminate the ssl at the ELB.
Add the DNS CNAME or A record entry for the new domain pointing to the old domain servers.
Post this it should work.
This is based on #mdeora's answer correct answer with some details.
1. Create a virtual host for the domain (my-domain.com) in the droplet
Copy default conf:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/my-domain.com.conf
Add a ServerName to the conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName my-domain.com
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the site: a2ensite my-domain.com.conf
Reload apache: systemctl reload apache2
2. Install a ssl certificate on the droplets server
(I did it using certbot)
certbot --apache -d my-domain.com
(follow the certbot instructions)
3. Create an A record in route53
Create an A record and point it to the ip of the droplet.
(4. update wordpress settings)
If you're running a wordpress site be sure to change wordpress url settings in admin to https://my-domain.com.
Now, hopefully, everything should work.
I have a site now with address https://example.com/. How to make possible access to this site also by address https://example.com.html? What to write in htaccess?
What to write in htaccess?
Nothing special.
The question is not what to write but what to not write in .htaccess. And the answer is: do not write anything that links the site to one of its names (example.com or example.com.html). The same applies to the PHP source or configuration files.
The rest is just proper names registration, nameserver and Apache configuration.
Regarding the configuration of Apache, let's say the IP address of your web server is 1.2.3.4. The Apache configuration file (httpd.conf f.e.) now contains something similar to this:
<VirtualHost 1.2.3.4:80>
ServerName example.com
DocumentRoot "/www/docs/example.com"
# Other configuration directives for domain example.com
</VirtualHost>
In order to let Apache know the domain example.com.html is the same as example.com you can add a ServerAlias to the <VirtualHost> block:
<VirtualHost 1.2.3.4:80>
ServerName example.com
ServerAlias example.com.html
DocumentRoot "/www/docs/example.com"
# Other configuration directives for domain example.com
</VirtualHost>
Assuming you already have the name and the name servers are properly configured to point to your existing server, restart Apache and it should work.
Read more about <VirtualHost> and ServerAlias
Okay so... i tried using
ServerName something.ooo
ServerAlias www.something.ooo
but it appears..
you can not use ServerAlias unless it is used within a
<VirtualHost *:80>
</VirtualHost>
Why is it like that?
What happens if the server is used only with 1 domain name and thus there is no need for "VIRTUAL" things. such as "VIRTUALHOSTS" ?
VirtualHost is designed to be used with multiple sites, however, when using an alias, Apache is assuming that you have example.com, and are wanting widget.example.com. With that said, just because it's only a www, does not mean that Apache doesn't see those as "separated" domains, thus needing a VirtualHost tag.
This is why you can use ServerName, but can't use ServerAlias without VirtualHost. WWW and non-www are separated domains.
Here's what I want to do:
Let's say i have www.mysite.com and it's a complex website with alot of files
I want to make fr.mysite.com, it.mysite.com, uk.mysite.com to access the file in the root website (ie: fr.mysite.com/jobs.php will actually load mysite.com/jobs.php but in the browser url it will show the link with subdomain).
I want to build a site with content from multiple countries and I want each country to be accessed with it's code as a subdomain. If I can do that I can then process the url in php and know what country code it's in the url.
Copying the entire site to each subdomain folder isn't an option.
Let me know if you have any idea on how to do that, I guess it's a .htaccess thingy but I can't figure it out .
Use ServerAlias in your VistualHost configuration: set it up as single virtual host where all sub-domains point into the same root folder:
<VirtualHost *:80>
ServerName mysite.com
ServerAlias *.mysite.com
DocumentRoot "\path\to\your\site\"
...
</VirtualHost>
This is the most recommended way -- no need to involve URL rewrite here.
I have, for example site1.com, site2.com, configured with their own virtual hosts in their own files in the apaches enabled and available folders, in their own physical folders on the server and with different .htaccess and they are working fine. Now I want all the other domains that are not separately configured (for example site3.com, site4.com ....) to have one same virtual host, same physical folder, and to execute the same /folder1/folder2/index.php file. So far, I've made some virtual hosts but all I get is "It's working", probably because everything is redirected from the default virtual host to the /var/www. But if I set the DocumentRoot directive in that file, the .htaccess for some reason is not working, and I said that for the defined sites are working OK. What the virtual host file should be called, what should be it's content?
You can define a VirtualHost container that has as many ServerAlias entries as you need.
Here's a very simplified example:
<VirtualHost *>
ServerName site3.com
ServerAlias site4.com
DocumentRoot /var/www/folder1/folder2
</VirtualHost>
If you've already tried creating vhost files, have you restarted apache?
Where to put the vhost files depends on what distro you're using. If you're not familiar with where stuff goes on your distro, check http://wiki.apache.org/httpd/DistrosDefaultLayout.