Redirect to HTTPS is missing a slash after the domain name

Redirect to HTTPS is missing a slash after the domain name - 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 Redirect to HTTPS is missing a slash after the domain name error on your web browser. Problem :


I just set up HTTPS on my server, and I have an issue with redirect permanent.


Example: http://example.com/index.html redirects me to http://www.example.comindex.html.


The / (tail ending slash) is missing and I can't figure out how to fix it.


It works with http://www.example.com/index.html.


Here is my httpd.conf


<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://www.example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.com
Redirect permanent / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
DocumentRoot /var/www/example/
ServerName www.example.com
SSLEngine on
SSLCertificateFile ssl.crt
SSLCertificateKeyFile ssl.key
</VirtualHost>

Solution :

Change to this and try it, notice only two VirtualHost


<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
Redirect permanent / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
DocumentRoot /var/www/example/
ServerName www.example.com
SSLEngine on
SSLCertificateFile ssl.crt
SSLCertificateKeyFile ssl.key
</VirtualHost>


I had that same issue, and don't know why it is failing either. I was able to work around it using this instead:


<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
# Redirect 301 / https://www.example.com
RedirectMatch permanent /(.*) https://www.example.com/$1
</VirtualHost>



Example: http://example.com/index.html redirects me to http://www.example.comindex.html.

The / (tail ending slash) is missing and I can't figure out how to fix it.



This will happen if you are missing the trailing slash from the end of the target URL-path on the Redirect directive, when the slash is included on the source URL. For example: Redirect / https://www.example.com or Redirect /subdir/ https://www.example.com/subdir - the slashes need to match.


However, this is not the case with the directives as posted in the question, since you appear to be including the trailing slash on the target URL. This should work as intended, and there is little that can override this. It is quite likely you are seeing a cached response due to an earlier erroneous "permanent" redirect. 301 redirects are cached persistently by the browser by default.


Test first with 302 (temporary) redirects to avoid potential caching issues.


We hope that this article has helped you resolve the redirects, apache, https 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=