• Resolved Tim F

    (@tim-f)


    Hi all,

    I recently moved my wordpress installation to new hosting under an addon domain. When I access the site at http://mysite.com, it redirects to https://www.mysite.com/mysite.com.

    I have googled and seen many other people with this problem and have checked and tried the following with no luck:

    Made sure the siteurl and home fields in wp_options in the database both start with http://
    Updated permalink settings in wordpress settings menu
    In wp-config.php, added the lines

    define('WP_SITEURL', 'http://mysite.com');
    define('WP_HOME', 'http://mysite.com');

    Added the following to the .htaccess file in public_html:

    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    Disabled any plugins that might affect redirects or URLs

    Can anyone suggest other things I might have missed here? One thing I noticed is it is redirecting to the https:// version, but I’m still waiting for my security certificate from my host. I had been trying to use the Really Simple SSL plugin but disabled it till I get the certificate so I’m not sure why it is redirecting to the https at the moment, could that be part of the problem?

    • This topic was modified 6 years, 5 months ago by Tim F.
    • This topic was modified 6 years, 5 months ago by Tim F.
    • This topic was modified 6 years, 5 months ago by Tim F.

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • $_SERVER['DOCUMENT_ROOT'] = '/www/home/user/public_html';
    I specified the root of the document to be as exhaustive as possible.
    You need to enable the rewrite engine and add the path to where your htaccess file resides.

    Good for root /www/home/user/public_html:

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # END WordPress

    RewriteBase is for root /

    You must copy your index.php file into root folder and edit
    Original:
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    /www/home/user/public_html:
    require( dirname( __FILE__ ) . '/new_path/wp-blog-header.php' );
    Now it /www/home/user/public_html/new_path
    If you use subfolder for WordPress.

    Unistalling

    Thread Starter Tim F

    (@tim-f)

    @autotutorial Thanks very much for the reply. Can I just clarify, which file does this go in:

    $_SERVER['DOCUMENT_ROOT'] = '/www/home/user/public_html';

    My current setup is one wordpress installation for my primary domain in the root folder public_html (working fine) and one wordpress install for an addon domain, so the install is in public_html/mysite.com. This means there is index.php for install 1 in root and index.php for install 2 in root/mysite.com. Does that change your instructions for index.php?

    Also I checked my .htaccess in root and all of those lines are present. Do I maybe need a separate .htaccess file for root/mysite.com?

    I created the path to specify where your wordpress is located (with a path it’s easier to explain), you don’t have to enter the global SERVER variable.
    If you use a different prefix for the database, both should work.
    Your htaccess has no domain limits but your hosting can impose such limits, ask your hosting for info.
    Currently you need to uninstall the plugin residues, I hope you read uninstall.

    sorry I did not understand, does the mysite.com folder exist for the second installation? If the answer is yes, mysite.com is correct in the url even if you should ask your hosting how to hide this folder in an addon domain. (normally the url starts with root).
    let me know what your hosting answers, otherwise you can solve in another way.

    The real problem is the redirect from the root to the mysite.com folder, can you indicate your two domains? (for privacy you can enter xxxx instead of the real domain, for example installation 1 example.xxxxx.com installation 2 subdomain.xxxxx.com)

    • This reply was modified 6 years, 5 months ago by autotutorial. Reason: Edit for missing content
    Thread Starter Tim F

    (@tim-f)

    @autotutorial Thanks again – I have tried completely manually uninstalling really simple SSL with no difference so have now reinstalled it as my certificate is now live.

    Yes the second WP installation (the problem one) is in public_html\mysite.com – only the http version of the url redirects to the wrong url. If I visit http://mysite.com, it redirects to https://mysite.com/mysite.com. If I visit https://mysite.com it loads correctly with no redirect.

    Thanks for pointing me in this direction, I will contact my host unless you or anyone else has any ideas?

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /mysite.com/
    RewriteRule ^mysite\.com/index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /mysite.com/index.php [L]
    
    # END WordPress

    you can try this htaccess for the second installation, of course you substitute mysite.com in your second installation also enter the backslash \?
    Please indicate your two domains?

    define('WP_SITEURL', 'https://mysite.com');
    define('WP_HOME','https://mysite.com/mysite.com');

    this is a temporary modification if your hosting confirms that the request to https://mysite.com is forwarded to your local path /www/home/user/public_html/mysite.com/ (this is just an example to distinguish the path for the second installation) the error is in the wordpress code and obviously also in the plugin used.

    Thread Starter Tim F

    (@tim-f)

    @autotutorial Thanks again for the help. Adding the .htaccess to the mysite.com did not change anything.

    However when I added

    define(‘WP_SITEURL’, ‘https://mysite.com’);
    define(‘WP_HOME’,’https://mysite.com/mysite.com’);

    To wp-config.php the URL is still doubled, eg visiting http://mysite.com still redirects to https://mysite.com/mysite.com but this link now works – there is no more page not found error and the site actually loads at the wrong url.

    to process the code I need to know the two domains .. the mismatched redirect is part of the browser cache used. (the value of the url shown to the browser, in wordpress WP_SITEURL makes this distinction).
    to verify that I’m on the right track, try visiting with the https protocol and the root.

    • This reply was modified 6 years, 5 months ago by autotutorial.
    Thread Starter Tim F

    (@tim-f)

    My host helped me identify the problem – embarrassingly it was browser cache. Posting this here so anyone else with this issue knows to clear browser cache as the first step. The great advice from @autotutorial may help if that doesn’t work.

    we are not done, replace mysite.com in your correct addon.
    use the chrome browser’s private mode.
    https://mysite.com/mysite.com/index.php
    https://mysite.com/mysite.com/
    https://mysite.com/index.php
    https://mysite.com/mysite.com/wp-json/
    to check that the requests use the redirect, use an online sniffer. https://websniffer.cc/?url=https://mysite.com/

    if something goes wrong replace your htaccess with this code.

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /mysite.com/
    RewriteRule ^(mysite\.com/)?index\.php$ - [L]
    RewriteRule ^mysite\.com(/)?$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /mysite.com/index.php [L]
    
    # END WordPress

    This code can be modified from WordPress, because it is enclosed by the WordPress propositive tags, meaning that it can be changed at any time.

    • This reply was modified 6 years, 5 months ago by autotutorial.
    Thread Starter Tim F

    (@tim-f)

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘URL redirects to doubled version’ is closed to new replies.