Redirect from to is instead going to

Posted March 31, 2017 2.4k views
ApacheUbuntu 16.04

I am using LetsEncrypt to add SSL certs to all my domains. I used the “force redirect to https” option when I set up the cert, which added the redirect to my *:80 virtualhost and created a *:443 virtualhost with the correct config. However, it’s behaving really strangely.

If you go to, it 301 redirects you to Nowhere in my config do I see a reason for that to happen, and I can’t figure out how to view the level of logs that would help me debug the issue.

Here are my conf files:

<VirtualHost *:80>

    RewriteEngine on
    RewriteCond %{SERVER_NAME}
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/
    ErrorLog /var/www/
    CustomLog /var/www/ combined

  <Directory /var/www/>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    allow from all
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
Include /etc/letsencrypt/options-ssl-apache.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Any help would be appreciated. Thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @ryangiglio
Looking at those two configurations, should never result in 301 to
Are you sure there might not be hiding a configuration somewhere else? Or maybe your .htaccess has some redirects?
Try running this to list all the VirtualHosts: sudo apache2ctl -S

  • Agreed - there’s nothing here that should be doing this which is why it’s so strange!

    The site doesn’t have an .htaccess file at all

    When I run sudo apache2ctl -S I see all the virtualhosts on the server, but I’m not sure what else I can learn from that.


    • @ryangiglio
      The sudo apache2ctl -S lists all the configuration files. Have a look in each of them to see if you might have made a tiny mis-configuration.
      Otherwise, you’re more than welcome to post all your configurations and we ( @jtittle and me ) will do our best to track down any issues.


I’m seeing something entirely different on my end, though neither redirect to anything when I access them.

When I visit, I see one site with two posts. It doesn’t redirect to www.

When I visit, I see an entirely different website.

When checking the IP they resolve to, they both resolve to the same IP address, so the issue here is configuration. Are there any other configuration files that you can provide? Something is separating the two and pointing to two entirely different directories from what I’m seeing on my end.

  • Sorry if I wasn’t clear on what I’m looking for/what the problem is

    What I want: When you visit it to redirect to and display the blog you see with 2 posts

    What it’s doing instead: Redirecting to and showing the “default” document root, which is an entirely different website that’s also hosted on this server under a different VirtualHost.

    What other config files would be helpful to include?


    • @ryangiglio

      We’d need to see all configuration files that handle that sub-domain as they one that you’ve provided wouldn’t cause two different sites to show up.

      If you take a look at the below, you’ll see what I mean by two different sites showing up and neither redirect.

      From the looks of the above, content is being pulled from two different directories.

      1). First screenshot is of
      2). Second screenshot is of