Viewing 6 replies - 1 through 6 (of 6 total)
  • Yes, that is possible. Save ‘https://dem0site.net’ in both boxes at Dashboard > Settings > General, then cPanel-assign and -point your domain to public_html and use this htaccess to redirect it to ‘wp-org-01’ (or wherever):

    # .htaccess main domain to subdirectory redirect
    # Do not change this line.
    RewriteEngine on
    # Change example.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    # Change 'subdirectory' to be the directory you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/subdirectory/
    # Don't change the following two lines.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Change 'subdirectory' to be the directory you will use for your main domain.
    RewriteRule ^(.*)$ /subdirectory/$1
    # Change example.com to be your main domain again.
    # Change 'subdirectory' to be the directory you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    #RewriteRule ^(/)?$ subdirectory/index.html [L]
    ## index.php for WordPress
    RewriteRule ^(/)?$ subdirectory/index.php [L]

    Visitors to your Web site will not be able to tell that your main domain is using a subdirectory, they will still see the Web site address as https://www.example.com/…

    https://my.bluehost.com/cgi/help/347#redirect

    Thread Starter NewBeeDev

    (@newbeedev)

    Thank you, so much, leejosepho, for taking the time to not only answer, but to do so with such a clear comments in the ‘.htaccess’ file! ??

    However, your changes above only fix issue #1. Now, hovering over the ‘Site Admin’ element of the ‘Meta’ widget shows (as desired): https://dem0site.net/wp-login.php (without the subdirectory).

    On the other hand, issue #2 remains. The image embedded into the “Hello world!” post is still located at: https://dem0site.net/wp-org-01/wp-content/uploads/2015/01/WordPressOrgIcon1-300×300.png (with the subdirectory).

    Could you so kindly provide a fix for also masking the subdirectory in images and other items in the ‘uploads’ directory?

    This link also displays that image:

    https://dem0site.net/wp-content/uploads/2015/01/WordPressOrgIcon1.png’

    So, I suspect that just needs to be updated in your database. Saving ‘https://dem0site.net’ in both boxes at Dashboard > Settings > General possibly should have taken care of that, but I have yet to not have to manually edit one or more links after moving a site.

    After making a database backup just in case something goes haywire, you might try this SQL at cPanel > phpMyAdmin for fixing that:

    UPDATE pref_options SET option_value = replace(option_value, 'https://dem0site.net/wp-org-01/wp-content', 'https://dem0site.net/wp-content') WHERE option_name = 'home' OR option_name = 'siteurl';
    
    UPDATE pref_posts SET guid = replace(guid, 'https://dem0site.net/wp-org-01/wp-content','https://dem0site.net/wp-content');
    
    UPDATE pref_posts SET post_content = replace(post_content, 'https://dem0site.net/wp-org-01/wp-content', 'https://dem0site.net/wp-content');
    
    UPDATE pref_postmeta SET meta_value = replace(meta_value,'https://dem0site.net/wp-org-01/wp-content','https://dem0site.net/wp-content');

    Thread Starter NewBeeDev

    (@newbeedev)

    Thank you, so much, once again, leejosepho!

    You were 100% correct. The fact that the URL for that image still referenced the subdirectory was due to the fact that it was added to the Media Library at a time when the “WordPress Address (URL)” (siteurl) still included that subdirectory.

    To verify this, I “dropped’ all of the tables is my database and recreated the site from scratch. Then, with your ‘.htaccess’ settings still in place, and only after removing the subdirectory from both the “WordPress Address (URL)” (siteurl) and “Site Address (URL)” (home), did I edit the the “Hello world!” post to include the image. And, lo and behold, the URL for that image was created without any reference to the subdirectory.

    Thanks a million! ??

    I will take the liberty of posting your answer (with credit to you) in WordPress.StackExchange.com, where I asked this same question but did not yet receive any answers.

    Thank you, so much, leejosepho, for taking the time to not only answer, but to do so with such a clear comments in the ‘.htaccess’ file! ??

    To be certain the credit lands where it should, that code comes from BlueHost where I learned all these things about “moving WordPress” without having to do anything tricky anywhere within WordPress.

    Thanks so much leejosepho, even if the info did originate from BlueHost. I just had the exact same issue as NewBeeDev and I got the same exact perfect solution. Hats off!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Mask *all* traces of subdirectory when "giving WordPress its own directory"?’ is closed to new replies.