htaccess Examples

On Linux/Apache servers, each user has access to a powerful tool called “.htaccess”.  When you create an .htaccess file and populate it particular code, you have a great deal of control over your hosting environment.  Everything from rewriting and redirecting web requests to password protecting a directory or document.  We will continue to update this article with snipets of commonly used .htaccess code.

Code for a 301 rewrite rule:  If you have the same domain name with different TLD’s, (domainname.com and domainname.org), and you want to rewrite one to the other without hurting your search engine rankings, you will want to implement a 301 rewrite.  Here is the basic code for your htaccess file:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainname\.com$ [NC]
RewriteRule ^(.*)$ http://www.domainname.org/$1 [R=301,L]

Comments are closed.


Bad Behavior has blocked 169 access attempts in the last 7 days.