Support » Fixing WordPress » Dev site redirects to live site on login

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter HairLoss57

    (@hairloss57)

    I should have added that I tried different browsers and cleared cookies and cache but to no avail.

    Hello @hairloss57

    Hope all is well!

    Please update the .htaccess file of the dev site and replace the rules with the below lines

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/wp/
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    Where /wp/ is the folder name, wher eteh devlopemtn opy is installed.

    Otherwise, please also try this solution:
    https://geekflare.com/redirect-subfolder-to-root-folder/

    Hope this helps!

    Cheers,
    Nastia

    Thread Starter HairLoss57

    (@hairloss57)

    Hi Nastia,

    Thanks for your prompt reply. I have tried both solutions but unfortunately without success.

    What do you think is happening to cause the redirect to the live site?

    Thanks.

    Thread Starter HairLoss57

    (@hairloss57)

    I think I see the problem. My sites are running on a VPS and each domain has it’s own Apache config file. I see in the config file that there is the line;

    DirectoryIndex /wordpress/index.php

    So I guess whatever calls the domain is going to get shunted into the /wordpress directory of the live site and not the /wp directory of the dev site.

    I will ponder a solution.

    Thread Starter HairLoss57

    (@hairloss57)

    When I change

    DirectoryIndex /wordpress/index.php

    to

    DirectoryIndex index.htm

    I can no longer run the script /wordpress/index.php – you do not have permission..
    Yet I can run /wordpress/hello.php. Both files have exactly the same permissions, owners and group.

    This is probably an apache issue but if anyone here knows the answer I would be grateful to here.

    Thanks.

    Thread Starter HairLoss57

    (@hairloss57)

    OK, it is ugly but I appear to have found a solution.

    In the apache config file;

    DirectoryIndex /wordpress/index.php

    has been changed to

    DirectoryIndex index.htm

    Additional directives were added;

    <Directory /var/www/vhosts/mydomain.com/httpdocs/wp>
    Options +ExecCGI
    DirectoryIndex index.php
    </Directory>

    <Directory /var/www/vhosts/mydomain.com/httpdocs/wordpress>
    Options +ExecCGI
    DirectoryIndex index.php
    </Directory>

    An index.htm document was added to the root directory with a redirect to send live users to /wordpress/index.php

    In the dev site the pretty permalinks had to be set to the default – mydomain.com/wp/?page_id=2

    Live users get directed to the live site when they type in the domain, I can access my development site simply by adding /wp onto the domain.

    I have been able to logon and create a couple of pages and to see these via the web.

    I anyone knows of a tidier solution please let me know but this will do for now.

    Cheers.

    • This reply was modified 3 years, 7 months ago by HairLoss57.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dev site redirects to live site on login’ is closed to new replies.