: Apache2 subdomain to domain [SSL] I have domain with SSL and 4 subdomains like: ftp.example.com, server.example.com etc. I'm trying to redirect from subdomain to domain. Example: if someone goes
I have domain with SSL and 4 subdomains like: ftp.example.com, server.example.com etc. I'm trying to redirect from subdomain to domain. Example: if someone goes to server.example.com they will be redirected to example.com. My apache2 config looks like that:
<VirtualHost *:80>
ServerAdmin info@example.com
DocumentRoot /home/www/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g. #LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf
# Redirect Requests to SSL
Redirect permanent / example.com/ </VirtualHost>
But not working.
More posts by @Frith620
2 Comments
Sorted by latest first Latest Oldest Best
Instead of a virtual host configuration, you can just create an CNAME record in your DNS for the subdomain to point to the main domain
if someone goes to server.example.com they will be redirected ....
The virtual host you posted is for port 80 (ie. HTTP) so this is never going to redirect <anything>. As the comment in the code suggests, "Redirect Requests to SSL" (from HTTP).
Exactly how you implement this depends on how the subdomains are implemented... are they separate virtual hosts or ServerAlias, etc.?
Depending on the implementation then the redirect you give should work if you have separate virtual hosts. However, if you have a single virtual host container then you may need to use mod_rewrite and check the host which is being accessed. But whether this works at all may be dependent on the type of SSL cert you have implemented.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.