0

I'm new to WordPress and have been developing a new website that will replace an old non-WordPress site. WordPress is currently installed in a subfolder whilst I've been creating the new site and it's now ready to go live. (Just to point out, it's a static website without any of the blog stuff going on).

There are two things I want to accomplish now and I think I know what needs to be done but I just want to confirm that I'm on the right track:

1) The current (old) website is on www.xyz.com and the new WordPress site is at www.xyz.com/wordpress. I want to make sure that when someone now goes to www.xyz.com, they get to the new WordPress site (i.e. www.xyz.com/wordpress).

  • in WordPress admin, go to Settings => General
  • change "Site Address (URL)" to be "www.xyz.com" (leave "WordPress Address (URL)" as "www.xyz.com/wordpress")
  • save changes
  • copy .htaccess and index.php from \wordpress subfolder into root (i.e. public_html)
  • open index.php and change:

    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    

    to be:

    require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
    

2) I don't want to have to include "index.php" in links to the new site; i.e. I want to be able to go to www.xyz.com/some_page and not have to use www.xyz.com/index.php/some_page

  • edit .htaccess file and include in it:

    # 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
    

    I'm not sure if that last RewriteRule line should include the /wordpress subfolder or whether it's not required due to the previous change to index.php? Or would I need to change it to:

    RewriteRule . /wordpress/index.php [L]
    

Thanks

2 Answers 2

0

I'd do it even simpler. Most hosting places allow you to specify where the root folder of your domain is. Just change that location, and the new WP site is available.

You shouldn't need to change anything; use the standard WP htaccess, and leave the wp-config.php settings alone.

I use a standard procedure of my own to move a site from a testing place to a new home (the new live site). It has worked for me much better than the backup/restore/move plugins. Takes a bit of effort, but has always worked well for me. You'll find it here: https://securitydawg.com/moving-a-wordpress-site/

There are other places that you can find 'moving' instructions; the googles will help you there. But I've used my process several times, and it has worked well for me.

1
  • Absolutely, just point your domain to the subfolder.
    – Hans
    Sep 28, 2018 at 23:29
0

The hosting provider does not allow changes to the document root for the primary domain (I believe this is not hugely uncommon amongst providers, including the likes of HostGator: https://support.hostgator.com/articles/cpanel/document-root-changes) ...hence the need for an alternative approach.

In case anyone's interested, the following was what worked for me:

  • go to Settings => General
  • change "Site Address (URL)" to be "www.xyz.com" (leave "WordPress Address (URL)" as "www.xyz.com/wordpress")
  • save changes
  • go to Settings => Permalinks (I had Custom Structure selected)
  • change from:

    /index.php/%year%/%monthnum%/%day%/%postname%/
    

    to:

    /%year%/%monthnum%/%day%/%postname%/
    
  • save changes

  • copy .htaccess and index.php from subfolder (wordpress) to document root (public_html)

  • open index.php in document root (public_html) and change:

    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    

    to:

    require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
    
  • edit .htaccess in document root (public_html) and add the following:

    # 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
    

I can now use www.xyz.com to access WordPress installed in the [wordpress] subfolder and also removed the need to include "index.php" in URLs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.