webserver

How do I modify my hosted .htaccess file for my website which is running WordPress?

If you have a hosting company and you install WordPress, the webhost will likely create a .htaccess file to handle WordPress.

A sample file looks like the one below:

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

In order to add a 301 redirect for example, you have to add it in the IfModule block, but above the config for WordPress.  Immediately after the RewriteEngine On line, you can add your config for the redirect(s).

A modified .htaccess file with a redirect is displayed below:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

#####################################
# 301 REDIRECTS                     #
#####################################

RewriteCond %{REQUEST_URI} /articles/linux/how-do-i-passwordless-ssh.htm
RewriteRule ^(.*) http://www.mytechforum.com/unix/how-do-I-passwordless-ssh/ [L,R=301]

#####################################
# WordPress Config             #
#####################################

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

Without putting the redirect in the correct location, it will not work as expected.

19 Comments

19 Comments

  1. product marketing

    July 15, 2010 at 11:20 am

    I just wanted to comment your blog and say that I really enjoyed reading your blog post here. It was very informative and I also digg the way you write! Keep it up and I’ll be back to read more soon mate

  2. Dick Delarme

    July 17, 2010 at 6:33 am

    I now possess the answers to my questions – at last! Thank you to get a fantastic web page. Gratefully, Beth

  3. Margret Darwich

    July 28, 2010 at 8:27 pm

    What a great post

  4. Clubs AZ

    August 9, 2010 at 8:30 pm

    Really informative blog post here my friend. I just wanted to comment & say keep up the quality work. I’ve bookmarked your blog just now and I’ll be back to read more in the future my friend! Also nice colors on the layout it goes well with the blog in my humble opinion 🙂

  5. joomla cpanel

    August 13, 2010 at 3:18 am

    I’m just googled around, and found your site. I’m very interested. Where can I find more info? Thank you!

  6. bluehost review

    August 13, 2010 at 10:52 am

    Thats lovely stuff you have written up on this blog. Been hunting for articles on this everywhere. Nice blog

  7. Telefon Schnurlos

    August 15, 2010 at 9:12 am

    the useful advice you provided helps my investigation for my company, thanks.

  8. Valda Nush

    August 17, 2010 at 9:09 am

    Great site!!!

  9. Tee Hamburg

    August 17, 2010 at 2:11 pm

    This is the best blog I have ever read thank you!

  10. seo

    September 3, 2010 at 4:26 pm

    Thanks for writing this I’ll tell my partner and see what she thinks.

  11. bonus codes

    September 4, 2010 at 6:32 pm

    A friend recommended that I check out your site. I’m glad that I’m here.

  12. Poker Download

    September 12, 2010 at 7:47 am

    I seldom leave comments on blogs, but you really impress me, also I have a few questions like to ask, what’s your contact details?

    -Johnson

  13. shanghai escort

    September 13, 2010 at 3:25 pm

    I’m impressed!!! Really informative blog post here my friend. I just wanted to comment & say keep up the quality work. I’ve bookmarked your blog just now and I’ll be back to read more in the future my friend! Also nice colors on the layout, it’s really easy on the eyes.

  14. replica ulysse nardin watches

    September 14, 2010 at 4:28 am

    oh cool, this information is really useful and definately is comment worthy! hehe. I’ll see if I can try to use some of this information for my own blog. Thanks!

  15. replica patek philippe watches

    September 14, 2010 at 5:18 am

    oh cool, this information is really useful and definitely is comment worthy! hehe. I’ll see if I can try to use some of this information for my own blog. Thanks!

  16. chanel bags

    September 14, 2010 at 8:59 am

    Wow, I found this site on yahoo searching for something completely different- now I’m gonna need to go through the archives XD So much for my spare time today, but this was a truly great find.

  17. cornell university college

    September 22, 2010 at 10:35 pm

    I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success.

  18. Bree Public

    September 27, 2010 at 7:19 pm

    Good to find out you back again. And again having an interesting posting.

  19. marketing experts

    October 5, 2010 at 4:12 am

    I got to this page through Facebook (one of my friends posted it). After checking your article, I then clicked Like and also reshared it.

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top