Hi, I know this has been asked many times before, but I couldn’t find any advice that fixes my issue.

I have a single droplet with two virtual hosts - 1. bytesizedgames.net 2. ryanmaskell.co.uk. Both are Wordpress installs, each in their own folder, /var/www/bytesiedgames.net/publichtml and /var/www/ryanmaskell.co.uk/publichtml.

Each has an apache config in /etc/apache2/sites-available and I’ve activated both using a2ensite and reloading/restarting apache. They look like this:

bytesizedgames.net.conf:

<VirtualHost *:80>

ServerAdmin admin@bytesizedgames.net
ServerName bytesizedgames.net
ServerAlias www.bytesizedgames.net
DocumentRoot /var/www/bytesizedgames.net/public_html

ErrorLog /var/www/bytesizedgames.net/logs/error.log
CustomLog /var/www/bytesizedgames.net/logs/access.log combined

<Directory />

Options FollowSymLinks
AllowOverride None

</Directory>

<Directory /var/www/bytesizedgames.net/public_html>

Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
Allow from all

</Directory>

</VirtualHost>

ryanmaskell.co.uk.conf:

<VirtualHost *:80>

ServerAdmin admin@ryanmaskell.co.uk
ServerName ryanmaskell.co.uk
ServerAlias www.ryanmaskell.co.uk
DocumentRoot /var/www/ryanmaskell.co.uk/public_html

ErrorLog /var/www/ryanmaskell.co.uk/logs/error.log
CustomLog /var/www/ryanmaskell.co.uk/logs/access.log combined

<Directory />

Options FollowSymLinks
AllowOverride None

</Directory>

<Directory /var/www/ryanmaskell.co.uk/public_html>

Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
Allow from all

</Directory>

</VirtualHost>

I have the A-records set up on Cloudflare both pointing to the server IP. Can’t for the life of me figure out why it’s not working so any help would be appreciated.

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.

×
1 answer

Hi @ryanmaskell1,

The configuration files look alright! In such cases, I always tend to look at two places.

The first one is checking if you have any .htaccess redirects configured. Most of the time, people copy their already existing .htaccess files for all their websites. If you’ve copied it as well, it means every rule in the .htaccess files related to one of the websites has been copied over to the second one.

The second option would be your database, did you by any chance again copy the database from the first website to the second one? If it’s so maybe there is a hardcoded link for the first website inside the second’s database. This one is even more valid as I can see your website is using WordPress.

Regards,
KFSys

  • Hi KFSys, thanks for reaching out with some suggestions, I really appreciate it.

    I took a look at the .htaccess files for both of my WordPress sites. I’m pretty sure I didn’t copy the .htaccess across, but this is what they both look like:

    ryanmaskell.co.uk:

    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            RewriteRule ^index\.php$ - [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]
    </IfModule>
    #END WordPress
    

    Here’s bytesizedgames.net:

    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            RewriteRule ^index\.php$ - [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    # BEGIN WP Cloudflare Super Page Cache
    # The directives (lines) between "BEGIN WP Cloudflare Super Page Cache" and "END WP Cloudflare Super Page Cache" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_headers.c>
            Header unset Pragma "expr=resp('x-wp-cf-super-cache-cache-control') != ''"
            Header always unset Pragma "expr=resp('x-wp-cf-super-cache-cache-control') != ''"
            Header unset Expires "expr=resp('x-wp-cf-super-cache-cache-control') != ''"
            Header always unset Expires "expr=resp('x-wp-cf-super-cache-cache-control') != ''"
            Header unset Cache-Control "expr=resp('x-wp-cf-super-cache-cache-control') != ''"
            Header always unset Cache-Control "expr=resp('x-wp-cf-super-cache-cache-control') != ''"
            Header always set Cache-Control "expr=%{resp:x-wp-cf-super-cache-cache-control}" "expr=resp('x-wp-cf-super-cache-cache-control') != ''"
    </IfModule>
    <IfModule mod_expires.c>
            Header unset Set-Cookie "expr=resp('x-wp-cf-super-cache-active') == '1'"
            Header always unset Set-Cookie "expr=resp('x-wp-cf-super-cache-active') == '1'"
    </IfModule>
    <IfModule mod_expires.c>
            ExpiresActive on
            ExpiresByType application/xml "access plus 0 seconds"
    </IfModule>
    <FilesMatch "robots\.txt">
            <IfModule mod_headers.c>
                    Header set Cache-Control "max-age=0, public"
            </IfModule>
    </FilesMatch>
    <IfModule mod_expires.c>
            ExpiresActive on
            ExpiresByType application/json              "access plus 0 seconds"
            ExpiresByType application/xml               "access plus 0 seconds"
            ExpiresByType application/rss+xml           "access plus 1 hour"
            ExpiresByType application/atom+xml          "access plus 1 hour"
            ExpiresByType image/x-icon                  "access plus 1 week"
            ExpiresByType image/gif                     "access plus 6 months"
            ExpiresByType image/png                     "access plus 6 months"
            ExpiresByType image/jpeg                    "access plus 6 months"
            ExpiresByType image/webp                    "access plus 6 months"
    ExpiresByType image/webp                    "access plus 6 months"
            ExpiresByType video/ogg                     "access plus 4 months"
            ExpiresByType audio/ogg                     "access plus 4 months"
            ExpiresByType video/mp4                     "access plus 4 months"
            ExpiresByType video/webm                    "access plus 4 months"
            ExpiresByType text/x-component              "access plus 1 month"
            ExpiresByType font/ttf                      "access plus 6 months"
            ExpiresByType font/otf                      "access plus 6 months"
            ExpiresByType font/woff                     "access plus 6 months"
            ExpiresByType font/woff2                    "access plus 6 months"
            ExpiresByType image/svg+xml                 "access plus 4 months"
            ExpiresByType application/vnd.ms-fontobject "access plus 4 months"
            ExpiresByType text/css                      "access plus 1 year"
            ExpiresByType application/javascript        "access plus 1 year"
    
    </IfModule>
    # END WP Cloudflare Super Page Cache
    # BEGIN WP-Optimize Browser Cache
    <IfModule mod_expires.c>
            ExpiresActive On
            ExpiresByType text/css "access 28 days"
            ExpiresByType text/html "access 28 days"
            ExpiresByType image/gif "access 28 days"
            ExpiresByType image/png "access 28 days"
            ExpiresByType image/jpg "access 28 days"
            ExpiresByType image/jpeg "access 28 days"
            ExpiresByType image/webp "access 28 days"
            ExpiresByType image/x-icon "access 28 days"
            ExpiresByType application/pdf "access 28 days"
            ExpiresByType application/javascript "access 28 days"
            ExpiresByType text/x-javascript "access 28 days"
            ExpiresByType application/x-shockwave-flash "access 28 days"
            ExpiresDefault "access 28 days"
    </IfModule>
    
    <IfModule mod_headers.c>
            <filesMatch "\.(ico|jpe?g|png|gif|webp|swf)$">
                    Header set Cache-Control "public"
            </filesMatch>
            <filesMatch "\.(css)$">
                    Header set Cache-Control "public"
            </filesMatch>
            <filesMatch "\.(js)$">
                    Header set Cache-Control "private"
            </filesMatch>
            <filesMatch "\.(x?html?|php)$">
                    Header set Cache-Control "private, must-revalidate"
            </filesMatch>
    </IfModule>
    
    #Disable ETag
    FileETag None
    # END WP-Optimize Browser Cache
    

    I tried dropping the database for ryanmaskell.co.uk and re-creating it, but the issue still persisted sadly. I even deleted the wp-config and stuck a basic index html in the folder but the redirect still happens so I’m at a loss.

    • Hi @ryanmaskell1,

      I just tested the website - ryanmaskell.co.uk, I can see the test index.html page. It seems like you fixed it, what was the issue or are you still experiencing the redirects?

      If you type in the following in your shell

      curl -IL ryanmaskell.co.uk
      

      What is the output?

      • Interesting, for me I get re-directed to the bytesized maintenance page…on multiple devices/browsers+incognito. It seems I can get to the test.html but if I just visit the URL there’s a redirect. Maybe it’s a wordpress issue, so i’ll try reinstalling it

        Output for curl is:

        HTTP/1.1 200 OK
        Date: Thu, 19 Nov 2020 15:46:18 GMT
        Content-Type: text/html
        Connection: keep-alive
        Set-Cookie: __cfduid=d886864578f11f45ea3083ac473953b581605800778; expires=Sat, 19-Dec-20 15:46:18 GMT; path=/; domain=.ryanmaskell.co.uk; HttpOnly; SameSite=Lax
        Last-Modified: Wed, 18 Nov 2020 14:01:55 GMT
        Accept-Ranges: bytes
        CF-Cache-Status: DYNAMIC
        cf-request-id: 0682c8734600000d32a03bc000000001
        Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=6RKas%2FqtKt1HeYjU62FOZfnpHlhJsf5NTzugE8X%2B%2F1Dpf8sNwzG02OG32YJHXXCGkJjffYvlqpocb6ipFouStI0%2FxhnkTYWCYMjmslhbWgIkZA%3D%3D"}],"group":"cf-nel","max_age":604800}
        NEL: {"report_to":"cf-nel","max_age":604800}
        Server: cloudflare
        CF-RAY: 5f4b10320dfd0d32-ARN
        
      • Fixed it! It was an SSL issue. I hadn’t run certbot for the second site and I guess because I chose the redirect option for the first domain during its SSL setup it went wonky or something. Thanks for your help!!

Submit an Answer