• Hi,

    i have started working with a new client and I wanted to move his live site to a local host set up on XAMPP for development. These are the steps i took.

    1) Copied all the files from cpanel to my testfolder in htdocs

    2) imported my database into a local database.

    3) changed my wp-config file with information from my new database

    Initially this worked but for some reason now when i got to localhost/websitename it redirects to the live site.

    Have I missed any steps? Thank you

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Sai29180

    (@sai29180)

    Ok I changed my url’s in the test database and it seemed to work however now when I try to login in through /wp-admin i get a

    “access forbidden 403 You don’t have permission to access the requested object. It is either read-protected or not readable by the server”

    I don’t know what to do, any help would be appreciated.

    Most likely related to permalinks. What’s your htaccess look like?

    I’m having a similar issue with wp-login.php. So I copied the code to a new file wp-login2.php and changed the links to same in the code, but this redirects to the production site.

    Accessing the https://localhost/mywordpress/wp-admin/ will forward me to the production site as well.

    Additionally, when clicking on different links from the homepage, I get redirected to https://localhost/, the XAMPP dashboard.

    rudym, some basics.

    1 – Have you created a new database for your new client (and updated wp-config.php)
    2 – Have you edited the wp-options table in the NEW database and changed both the “siteurl” AND the “home” fields in wp_options.

    Ted

    1 – Yes, initially set up to reflect the same creds as the public.
    2 – Yes, one of the first things that are done upon importing the SQL data.

    Righto… I’ve had this problem before, so it is fixable.

    1 – Do you have anything exotic in your htaccess? If not, then I would suggest (re)saving the permalink settings.

    2 – Is your site on-line or offline (just wondering whether I can see it directly)?

    3 – Can you identify a page/post that reverts to live site? I think we need to “pull that page apart” to see what is happening.

    T

    1 – Not that I’m aware of, but yes, this is another issue I’m looking into. Seems like the links don’t work until I just click to view the permalink settings from the dashboard. Then the links work ok after.

    2 – No, this is a local setup I’m working with now.

    3 – This is no longer an issue once the plugins have been disabled. I think it was one of the plugins that handled redirects automatically for SEO purposes.

    Until you click to view permalink settings?? Wow, that’s weird. But you did SAVE the permalinks, didn’t you?

    So, are you still trying to find a solution, or did you disable plugins as part of your investigations?

    T

    No, I didn’t have to click save, just load the page. I’ve been trying to do something using WP-CLI to see if I can produce similar results without logging in. The commands I’ve tried so far, to no avail, are:

    wp rewrite flush –hard –path=c:\xampp\htdocs\mywordpress

    wp cache flush –path=c:\xampp\htdocs\mywordpress

    As for the solution to my other problem, I’ve resorted to just disabling the plugins, since it’s for development anyways.

    hi Sai29180

    moving a website to local environment is little tricky, but it seems to me you’ve a great amount of knowledge, so you will be fine!

    1) start everything over.

    2) replace every url to your local url in your database file, and then import into database.

    3) make changes in wp-config.php file for database name, user, password and host. (change host to “localhsot” if that something else).

    4) make changes in .htaccess file in wordpress main directory, it’s same as the wp-config.php file is located.

    note: .htaccess is a hidden file, so you cant see this file in normal file explorer, use ftp client to browse into it, don’t be confused if .htaccess file is not in the wordpress site folder, like you said in your post i’ve downloaded your site via cpanel, it is possible you’ve lost your original .htaccess file, because some cpanel does that, but its not big deal, you can open the web server via ftp client to download it or simply just create it a new one in you local webpress installation folder.
    you can create this file in any text editor just make sure the name of the file is .htaccess and has no file extention like .php or html etc.

    add the code in .htaccess file:

    # BEGIN WordPress
    <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

    5) you might have to change your webpress installation folder and file permissions, in order to function properly like to installing or updating wordpress or plugins etc.

    a) if using mac, paste this code in bottom of your wp-config.php file.

    /* WordPress All Privileges for Localhost */
    define('FTP_HOST', 'localhost');
    define('FTP_USER', 'daemon');
    define('FTP_PASS', 'xampp');
    if(is_admin()) {
    add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
    define( 'FS_CHMOD_DIR', 0751 );
    }

    b) you need to set your wordpress site permissions to 751 or 777, what ever your needs are.
    you can change this permissions manually or install some kind of app for it like BatChmod.

    that’s all if you’re moving a regular wordpress, if any any case you are moving a multisite, there will be additional steps, let me know if that’s the wordpress multisite!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Localhost redirects to live site’ is closed to new replies.