Some .Htaccess Redirect Snippets

I was editing some .htaccess files for a couple of my other sites the other day and thought these snippets would be helpful.

Leave a comment if you liked them. Enjoy!

Htaccess-snippets

Ok, to start off with, the snippet below will append all requests on your site with “www”. Additionally, if your sites does this and you haven’t put this code inside your .htaccess file, you could use Matt’s plugin “No WWW” to solve your problem.

//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.org/nl[nc]
RewriteRule ^(.*)$ http://www.example.org/nl/$1 [r=301,nc]

Additionally, if you like to redirect a directory or your domain to point to another location. You could post this code inside of your .htaccess file and replace example.org with your own domain.

//301 Redirect Site/Directory
RedirectMatch 301 example.org(.*) example.org/nl/$1

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.