GWIOD – what htaccess code goes in the website root htaccess file?

Home Forums BulletProof Security Free GWIOD – what htaccess code goes in the website root htaccess file?

Tagged: ,

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #8624
    AITpro Admin
    Keymaster

    Email Question:

    Okay, so I’ve been using BPS for years and am very happy with it. But I’ve run into an issue — I’ve Googled my ass off and cannot for the life of me find out what I need to do.

    The situation is as follows: I use BPS Free + W3 Total Cache. I have just updated my WordPress (which is an Own Directory install) to 3.6 and BPS to the latest. I tried to make sure everything works as it should, but I’m getting super completely confused by which .htaccess is which, because I have two. #1 is in the root folder and has the standard WP code and W3 TC code in it, #2 is in the WordPress folder (/portfolio/) and has the BPS code in it (but not the aforementioned stuff).

    My question: is this correct? Do both plugins work correctly? Or should I have copy/pasted the .htaccess file that is in /portfolio/ to the root? If so, which RewriteBase, if any, do I change?

    Thanks in advance for your assistance!
    Sincerely,
    Rémy

    #8625
    AITpro Admin
    Keymaster

    What is the name of the Portfolio plugin?  Do you see an error in your BPS Security Log?  Post the error that is related to the Portfolio plugin.

    #8626
    AITpro Admin
    Keymaster

    Email Reply:

    As for my issue: I do not see an error in my BPS Security Log, though I did just clear that. Also, “Portfolio” is not a plugin, it is where my WordPress installation resides [domain name removed for privacy]/portfolio/) seeing as WP has its own directory. Hence there being an .htaccess file in both the root and the /portfolio/ directory.

    #8634
    AITpro Admin
    Keymaster

    I assume then that you have a GWIOD website – “Giving WordPress Its Own Directory” website.

    With a GWIOD website you only need to use the standard default WordPress .htaccess file in the root folder without any other code in it. No additional BPS .htaccess code and no additional W3TC .htaccess code (i think, I am not 100% sure about whether or not W3TC requires caching code in the website root folder .htaccess file or not).

    /.htaccess – standard WordPress .htaccess file and the RewriteBase is / and RewriteRule is /index.php.
    You would use the Activate buttons for a GWIOD site just like any other WordPress site type.

    #8637
    John Doe
    Participant

    Ah, well, it seems that W3 Total Cache is putting its rewrite code in that .htaccess, though. Is that not supposed to be in that particular file? I’ve verified that the RewriteBase and RewriteRule is set correctly in that file, by the way.

    I had indeed been successfully using the Activate buttons for my GWIOD site up until now, but I got confused when W3 came into the mix.

    The current state of affairs is now as follows.
    /.htaccess: WP stuff and W3
    /portfolio/: just BPS

    I suppose that’s correct then?

    #8638
    AITpro Admin
    Keymaster

    Ok good to know about that W3TC adds its .htaccess code to the website root folder .htaccess file.  I was not sure since it has been a very long time since I tested W3TC on a GWIOD site, but that makes complete sense.

    Yes, everything seems correct.  Is everything working correctly?

    #8651
    John Doe
    Participant

    Everything does indeed to be working correctly. Thank you very much for clearing things up for me so quickly!

    AITpro has always had a fantastic support channel; it even outclasses most paid services. And I should know — I’m dealing with a fair amount of incompetence at the hosting support level right now, and that’s the stuff I pay for… Keep up the good work!

    #30500
    jenni101
    Participant

    Hi there,

    Getting a bit confused with what’s needed in the default .htaccess file that goes in the root of the site. Should it reflect the root? or the sub-directory where the actual wordpress site is located? So if my sub-directory wp install is in a folder called ‘myphotosite’, should it be this?…

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    or this, in the root?

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /myphotosite/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /myphotosite/index.php [L]
    # END WordPress

    Many thanks, j

    #30501
    AITpro Admin
    Keymaster

    @ jenni101 – Do have a GWIOD site installation?  What do you see when you go to WordPress > Settings > General > WordPress Address (URL) and Site Address (URL).

    The settings for a GWIOD site installation will look like this:
    WordPress Address (URL):  http://www.example.com/blog
    Site Address (URL):  http://www.example.com/

    blog is the folder where WordPress is installed and that is called your WordPress installation folder.
    The parent directory, which is usually the Hosting Account root folder/Document Root folder is called the website/site root folder.

    CORRECTION:  If you have a GWIOD site type then the site root htaccess file would use RewriteBase / and your BPS Root htaccess file that is created in your WordPress installation folder would use RewriteBase /blog/
    BPS does not create another htaccess file in the website root folder. So you would have to manually add an htaccess file to the site root folder by copying the standard BPS default.htaccess file to the site root folder and then edit it and add RewriteBase /blog/. Normally you should not have to create this additional htaccess file in the site root folder since WordPress creates the site root htaccess file by default.

    If you do not have a GWIOD site type and you have a subdirectory WordPress installation installed in a folder named /blog/ then this is your RewriteBase /blog/

    If are asking about customizing your default.htaccess file using the htaccess File Editor then BPS creates that customized default.htaccess root htaccess file in the WordPress installation folder and not the site root folder.

    #30516
    jenni101
    Participant

    Hi Ait-pro,

    Thanks for the detailed info. Yes I have a GWIOD site with settings like yours as above and with nothing in the root, and the wp install in it’s own folder.

    So I’ll copy the default .htaccess to the root and add the subfolder name to it as mentioned.

    Sorted! Thanks, j

    #30648
    jenni101
    Participant

    Hi again,

    Just trying to sort out a few other points for the root .htaccess file where my website is installed in a subfolder – ie. GWIOD setup as above.

    So initially the code i had in this root .htaccess was, as suggested, like this:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /subfoldersite/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
    

    Then i unlocked the root .htaccess file and added in redirects for my alternate domains AND redirects for the alternate domains of my Addon site, via cPanel, so the code now looks like this:

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /subfoldersite/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    
    # END WordPress
    
    # redirects for mysite and myaddonsite alternate domains
    # added in cPanel by JP
    RewriteCond %{HTTP_HOST} ^myaddonsite\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.myaddonsite\.com$
    RewriteRule ^/?$ "http\:\/\/myaddonsite\.co\.nz" [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mysite\.co\.nz$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mysite\.co\.nz$
    RewriteRule ^/?$ "http\:\/\/mysite\.com" [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mysitephotography\.co\.nz$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mysitephotography\.co\.nz$
    RewriteRule ^/?$ "http\:\/\/mysite\.com" [R=301,L]
    

     

    And finally I added in some code that was in my original root installed site, which was added to ensure that the root .htaccess code didn’t apply to my addon site OR another part of my site that is run with separate software (as an image library). So the final root .htaccess looks like this:

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /subfoldersite/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    
    # END WordPress
    
    # redirects for mysite and myaddonsite alternate domains
    # added in cPanel by JP
    RewriteCond %{HTTP_HOST} ^myaddonsite\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.myaddonsite\.com$
    RewriteRule ^/?$ "http\:\/\/myaddonsite\.co\.nz" [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mysite\.co\.nz$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mysite\.co\.nz$
    RewriteRule ^/?$ "http\:\/\/mysite\.com" [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mysitephotography\.co\.nz$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mysitephotography\.co\.nz$
    RewriteRule ^/?$ "http\:\/\/mysite\.com" [R=301,L]
    
    # To NOT apply rules to other CHILD websites or ADDON DOMAINS and 
    # to not log errors for these child sites
    # and the RewriteRule for Custom Apps (StockBox) outside of WP
    RewriteRule ^myaddonsite.co.nz/ - [L]
    RewriteRule ^myaddonsite.com/ - [L]
    RewriteRule ^/imagelibrary/ - [L]
    

    So my questions are:

    1. Should all of this code be ‘wrapped’ in the
      # BEGIN WordPress - # END WordPress

      wrapper text?

    2. Is this the correct place for my redirects? Or should it go in the root of each wp install, rather than the root?
    3. Do I still need the ‘not apply rule’ for my addon site and my other app (imagelibrary) that sits in it’s own separate folder, now I no longer have a root installed site?

    Look forward to your thoughts,

    with thanks, j

    #30658
    AITpro Admin
    Keymaster

    @ jenni101 – I accidentally reversed the correct RewriteBase code for GWIOD sites and have corrected that above.

    CORRECTION:  If you have a GWIOD site type then the site root htaccess file would use RewriteBase / and your BPS Root htaccess file that is created in your WordPress installation folder would use RewriteBase /blog/

    Your cPanel htaccess redirect code that you added would ONLY work if you are adding that cPanel htaccess code in the hosting account root folder htaccess file, which should also be your site root GWIOD htaccess file for your “myphotosite” site.

    I do not recommend that you use the cPanel htaccess code (or the cPanel tool at all and you should disable or turn it off) in your hosting account root htaccess file.  I recommend that you instead use this code below to not apply the security rules from your hosting account root htaccess file to any child sites below your hosting account root folder.  If the other child sites are WordPress sites then you would use this htaccess code in this link in BPS Custom Code for each of those individual child sites BPS root htaccess files to rewrite non-www to www URL’s:  http://forum.ait-pro.com/forums/topic/htaccess-redirect-www-to-non-www-htaccess-redirect-non-www-to-www/#post-1723

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
    
    # To NOT apply rules to other CHILD websites or ADDON DOMAINS and 
    # to not log errors for these child sites
    # and the RewriteRule for Custom Apps (StockBox) outside of WP
    RewriteRule ^myaddonsite.co.nz/ - [L]
    RewriteRule ^myaddonsite.com/ - [L]
    RewriteRule ^imagelibrary/ - [L]
    #30659
    jenni101
    Participant

    @ ait-pro – thanks for your help.

    Ok I keep reading and re-reading this:

    CORRECTION:  If you have a GWIOD site type then the site root htaccess file would use RewriteBase / and your BPS Root htaccess file that is created in your WordPress installation folder would use RewriteBase /blog/

    and I think I’ve got it the correct way around now but would like to double check with you, as for some reason it really confuses me!…

    So just to clarify (again I’m afraid!)… with my main wp site in its own subfolder called ‘tpphoto‘, and nothing in the root, + one Addon domain in its own subfolder and one non-wp install in its own subfolder called ‘imagelibrary’, so the site structure looks like this:

    public_html root folder
    – tpphoto subfolder (main wp site)
    – Addon domain subfolder (wp addon site)
    – imagelibrary subfolder (non-wp site/software)

    my public_html root folder, root .htaccess file would have this in it:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /tpphoto/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
    
    # To NOT apply rules to other CHILD websites or ADDON DOMAINS and 
    # to not log errors for these child sites
    # and the RewriteRule for Custom Apps (StockBox) outside of WP
    RewriteRule ^myaddonsite.co.nz/ - [L]
    RewriteRule ^myaddonsite.com/ - [L]
    RewriteRule ^imagelibrary/ - [L]

    And then in each wp install in it’s own folder/.htaccess file I’d add the redirects for the non-www to www code. So for example in my wp install in the tpphoto subfolder the code would look like this:

    # BEGIN WordPress
    # and Rewrite non-www to www
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    Does this look correct?

    Thanks, j

    (PS: does it also need this code within the Begin/End wp section?

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    etc…..
    </IfModule>
    # END WordPress

    as it shows it like this some places… Thanks.)

    #30660
    AITpro Admin
    Keymaster

    Nope.  The htaccess file in your hosting account root folder /public_html/ (or the hosting account root folder name for your web host) would have the file and code I posted above in it.  I’m assuming the tpphoto site is your GWIOD site and your site root htaccess file is in your hosting account root folder.  The second code you posted is correct for non-www to www rewriting, but if the  tpphoto site is your GWIOD site then this is the RewriteBase /tpphoto/.

    You can add any help text commented out that you want to add in your htaccess files: # Example text, # More Example text, # Some more example text…………..

    #30663
    jenni101
    Participant

    Ok so i just need to switch them around. So the tpphoto site (GWIOD site) would have the RewriteBase /tpphoto/ (to match it so to speak) in it.

    And would it have to be added to the other bit too, so it shows the correct path to the index.php?

    so it becomes this?

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /tpphoto/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /tpphoto/index.php [L]
    # END WordPress

    Thanks.

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.