Search code examples
phpwordpress.htaccess

Wordpress clone in subdirectory


I am trying to make a clone of a Wordpress site into a subdirectory. So, I will have two installations, one in the root of the domain, and one in /test. My problem is that, even though I have changed the values for siteurl and home uri in database, my links will redirect to root. So, a page like domain.com/test/contact will redirect to domain.com/contact, which is not what I want.


Solution

  • You need to follow these steps to clone your WordPress website from production to staging server -

    1. First export database of production server WordPress website and open SQL file in an text editor.
    2. Then find your domain name(domain.com) and replace it at all places with your domain name/test like domain.com/test.
    3. Import production SQL file to test database from phpmyadmin.
    4. Open staging WordPress admin like domain.com/test/wp-admin and go to Settings > Permalink section. Just click on the Save button to update htaccess file.
    5. Optionally you can go to setting at admin page and save all general settings, menus and check Widgets area too.
    6. Now you can access your domain.com/test WordPress website.