Apache2 subdomain to domain [SSL]

Apache2 subdomain to domain [SSL] - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Apache2 subdomain to domain [SSL] error on your web browser. Problem :


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 https://server.example.com they will be redirected to https://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 / https://example.com/
</VirtualHost>


But not working.


Solution :


if someone goes to https://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 https://<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.



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


We hope that this article has helped you resolve the redirects, https, apache2 error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=