Forums

Where to add code in htaccess file (20 posts)

  1. soullotus
    Member
    Posted 4 months ago #

    I have a very basic question. I have code that I need to add to my htaccess file. I have the code, and I know how to add it using ftp. But I don't know where to add it in the file.

    Where in the file do I add:

    Options +FollowSymLinks RewriteEngine On

    And I mean where EXACTLY do I add it? I don't know the rules about how to actually insert the code correctly. Could someone point my to the right place?

    Thanks

  2. Depending on your hosts Apache server configuration, that may not work. Also that's not one line, that 2 separate lines.

    Make a backup copy of your .htaccess file and add the options part only to the top of your file (1st line).

    Options +FollowSymLinks

    If you enable fancy permalinks, the RewriteEngine On will be added automatically and safely wrapped in a <IfModule...>.

    If you do edit that file and Very Bad Things™ happen, then restore that backup copy you've made.

  3. soullotus
    Member
    Posted 4 months ago #

    Thanks Jan,

    My hosting co. told me to add this. I'm trying to set up the Super Cache plugin.
    This is what's there right now:

    # BEGIN WPSuperCache
    # END WPSuperCache

    # 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

    So, are you saying to NOT add the RewriteEngine On anywhere? (is that because it's already written in there?) And where do I enable fancy permalinks? Thank you.

  4. MickeyRoush
    Member
    Posted 4 months ago #

    First,

    RewriteEngine On

    Needs to only be in there once. That's why it's usually placed before your first mod_rewrite directive. But don't worry about that now.

    WP Super Cache will look for

    # BEGIN WordPress

    and places it's rules directly above it and I believe it includes the above RewriteEngine On directive.

    Options +FollowSymLinks

    Needs to be at the very top of your .htaccess file, if not the first directive, depending on what else you have. It varies for server set up. Can't guess 100% correctly unless we see all of your .htaccess.

  5. MickeyRoush
    Member
    Posted 4 months ago #

    So:

    Options +FollowSymLinks
    # BEGIN WPSuperCache
    RewriteEngine On
    RewriteCond% blahblahblahblah-some-rules-for-wp-super-cache
    # END WPSuperCache

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

  6. soullotus
    Member
    Posted 4 months ago #

    Thank you Mickey! And that is all the .htaccess. I am just beginning this site. Nothing on it yet really. I already have the Super Cache installed. Not sure what the RewriteCond% is. I don't know anything about code, so bear with me. ;) If I already have it installed, and this is all that shows up in my htaccess, where does the blahblah...code come from? Is it something I have to add in there? Or just leave it as RewriteCond%?
    Hope my question makes sense.

  7. MickeyRoush
    Member
    Posted 4 months ago #

    soullotus wrote:

    Thank you Mickey! And that is all the .htaccess. I am just beginning this site. Nothing on it yet really. I already have the Super Cache installed. Not sure what the RewriteCond% is. I don't know anything about code, so bear with me. ;) If I already have it installed, and this is all that shows up in my htaccess, where does the blahblah...code come from? Is it something I have to add in there? Or just leave it as RewriteCond%?
    Hope my question makes sense.

    Oh, just ignore that RewriteCond% RewriteCond% blahblahblahblah-some-rules-for-wp-super-cache. I just put that there to represent any rules that WP Super Cache places in your .htaccess file.

    Are you saying there is nothing between these lines:

    # BEGIN WPSuperCache
    # END WPSuperCache

    If so then your .htaccess should look like this:

    Options +FollowSymLinks
    # BEGIN WPSuperCache
    # END WPSuperCache

    # 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

  8. soullotus
    Member
    Posted 4 months ago #

    Right. I copy and pasted the whole htaccess file, so there's nothing else. I really appreciate all your help. Thanks so much.

  9. soullotus
    Member
    Posted 4 months ago #

    Ok, so I have another question. I thought I knew how to use ftp, but I guess not. After I changed the code in the .htaccess file, I uploaded it into my public_html. It was in the form of a text document. The original .htaccess file was also there.
    I obviously am doing something wrong. Probably more than one thing.
    And words of wisdom would be welcome. Thanks

  10. kmessinger
    Member
    Posted 4 months ago #

    Just rename the files. The old, .htaccess to htaccess.old and the new to .htaccess

  11. soullotus
    Member
    Posted 4 months ago #

    Thanks for answering. So I don't delete the old file?

  12. kmessinger
    Member
    Posted 4 months ago #

    You can do that also.

  13. soullotus
    Member
    Posted 4 months ago #

    Thanks a bunch!

  14. soullotus
    Member
    Posted 4 months ago #

    OK, I have no idea what is going on. I just went to do the above steps. I looked in the .htaccess file that I had copy and pasted the other day and put above. Now, it looks like this (sorry it's so long). What is going on? Is this what it's supposed to look like with super cache? Just want to make sure I haven't been hacked. Thanks

    [Code moderated as per the Forum Rules. Please use the pastebin]

  15. kmessinger
    Member
    Posted 4 months ago #

    I am pretty sure you have been hacked.

  16. kmessinger
    Member
    Posted 4 months ago #

    Is your url soullotus.com?

  17. soullotus
    Member
    Posted 4 months ago #

    Yes, I was hacked. Could someone please tell me what I did wrong, and how to do it right next time so this doesn't happen again?
    I used Filezilla to add some code to the .htaccess file. I then uploaded it into my root directory. It had to have happened somewhere in that process. Thanks

  18. kmessinger
    Member
    Posted 4 months ago #

  19. soullotus
    Member
    Posted 4 months ago #

    Thanks again for all your help!
    One more question. I have shared hosting. This hack occurred on a subdomain that I had just installed. It was then uninstalled and reinstalled by them. They told me that would take care of it? I know they also scanned my main domain. (Looks like they used Sucuri.net)
    If a file gets hacked in the subdomain, is there a good chance that they can also infiltrate my main domain, which I've had for awhile? And would a scan pick everything up? That's the one I'm worried about, not the one in creation mode.

  20. kmessinger
    Member
    Posted 4 months ago #

    If a file gets hacked in the subdomain, is there a good chance that they can also infiltrate my main domain, which I've had for awhile?

    I don't know.

    And would a scan pick everything up?

    I wouldn't bet on that.

    Most likely other sites on the shared server where hacked also. Everything on the server needs to be cleaned up or it will happen again.

Reply

You must log in to post.

About this Topic