• I am working for a small organization to update their site to a new/fresh WordPress theme. Things are going well, but I do not know that much about .HTACCESS files and theirs seems to have a lot of stuff in it that I don’t know what it does or if it is even still correct or valuable. The site was built using a “custom theme” and is probably over 10 years old, and so I want to get is all streamlined and updated. I know some basic WordPress and CSS, but .HTACCESS is a bit beyond me, although I do know that it helps control the way the Apache server behaves and controls things like directory browsing and redirects.

    I want to make sure that this file is clean and nothing old/unnecessary in it, as well as to add in any key security or performance measures that may be missing.

    I think some of the stuff in the .HTACCESS file seems ok and appears to be standard .HTACCESS stuff for wordpress sites, but other lines I’m not sure if they should stay in or should come out.

    For example, do you need the code about the output compression, and is that only for php4, which probably isn’t even being used by our site anymore?

    And some things look like they are already commented out (with the “#” in front of them, so I presume I can just remove them entirely from the file?

    And toward the end, it looks like a whole bunch of 301 redirects, but not in a format I am familar with.. and I’m not sure all these domains are even in existence any more by this organization, so can I just remove any lines for domains that don’t exist anymore?

    Thanks for the help.

    Regards,

    Michael

    Here is the .HTACCESS file contents below.

    ——————————————————

    # http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/

    # secure htaccess file
    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>

    # preserve bandwidth for PHP enabled servers
    <ifmodule mod_php4.c>
    php_value zlib.output_compression 16386
    </ifmodule>

    # disable the server signature
    ServerSignature Off

    # set the server timezone
    SetEnv TZ America/New_York

    #asterisk
    ## disable directory browsing
    #Options All -Indexes
    #asterisk

    # prevent folder listing
    IndexIgnore .htaccess *.php *.txt

    # Use PHP5 as default
    # Use PHP5 Single php.ini as default
    # AddHandler application/x-httpd-php5s .php

    # php_value session.save_path ‘/tmp’

    Options +SymLinksIfOwnerMatch

    # For security reasons, Option all cannot be overridden.
    #Options All -Indexes
    Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes

    <files wp-config.php>
    Order deny,allow
    deny from all
    </files>

    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^ioresourcecenter.com [OR]
    RewriteCond %{HTTP_HOST} ^www.ioresourcecenter.com$ [OR]
    RewriteCond %{HTTP_HOST} ^informationoverloadresourcecenter.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.informationoverloadresourcecenter.com$ [OR]
    RewriteCond %{HTTP_HOST} ^informationoverloadresourcecenter.org$ [OR]
    RewriteCond %{HTTP_HOST} ^www.informationoverloadresourcecenter.org$ [OR]
    RewriteCond %{HTTP_HOST} ^www.informationoverloadresources.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.iorgforum.com$ [OR]
    RewriteCond %{HTTP_HOST} ^iorgforum.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.iorgforum.org$
    RewriteRule (.*)$ http://iorgforum.org/$1 [R=301,L]
    #RewriteRule ^/?$ “http\:\/\/informationoverloadresources\.com” [R=301,L]

    # 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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator t-p

    (@t-p)

    What goes in the .htaccess file and what does not, is site specific.

    Here is a general help guide: https://codex.wordpress.org/htaccess

    1. Backup the .htaccess file. You must be able to replace this one if the site goes down. Clearly you have direct access, so make sure you have that file saved and know how to find it (and replace it).

    2. Using FTP or your Host provided File Management tool(s), DELETE the file.

    3. Now, log into the site. Go to admin dashboard (must be admin)>settings>permalinks

    4. Simply save your current settings.

    5. Wait a few minutes, then load the site. Is the issue fixed?

    6. We can all check security issues at:

    https://sitecheck.sucuri.net/

    Everything as far as

    <files wp-config.php>
    Order deny,allow
    deny from all
    </files>

    is security rules. Nothing wrong with those being there, but they can be removed.

    The next block starting RewriteEngine on is rewrite rules as you noticed. These are probably for old pages that had some SEO value and then were deleted. To save the SEO benefit, these old pages are now redirected to the homepage.

    The final block are the WordPress permalink rules so that the page urls are written as sitename.com/page-name for example, rather than sitename.com/1236?.

    All the lines starting with the hash symbol # are comments to help understand or remind the function of the rule.

    As Pioneer Web Design suggested, you should always take a backup of the file before making any changes.

    In summary, I don’t see anything there that would slow the site down. The security rules add another layer of hardening, the rewrite rules will only come into play if those specific pages are requested, and the WordPress rules are essential to have pretty permalinks.

    Thread Starter einstem

    (@einstem)

    Ok.. Thanks. I don’t think we need all those old redirects anymore – those domains aren’t even owned by this organization any longer, so I plan to comment those out.

    I have figured out most of the other code, but there are two lines that I don’t know what they do that I still need some help with:

    Options +SymLinksIfOwnerMatch

    Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes

    Any idea what the above two lines do?

    Thanks.

    Michael

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Need help with .htaccess file’ is closed to new replies.