.htaccess
What is htaccess? .htaccess
(Hypertext Access) is the default name of Apache's directory-level
configuration file. It provides the ability to customize configuration
directives defined in the main configuration file.
Your web sites .htaccess, is often used for redirections, custom error
pages or password protected directories.
Redirection
One of the most useful functions of the .htaccess file is to redirect
requests to different files, either on the same server, or on a completely
different web site. e.g.
Redirect /location/file.ext http://www.new.com/new.xyz
301 Redirect from one domain to another
Redirect 301 / http://www.domainname.com/
Rewrite
It is best to have all of your traffic coming to either yourdomain.com
or www.yourdomain.com,
not both. This will get all of your traffic going to www.yourdomain.com.
Put this in your .htaccess file:
# REWRITE RULES
Options +SymlinksIfOwnerMatch -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</IfModule>
Variation for shared SSL
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Do not allow requests for images
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/copyright.gif [R,L]
Custom error pages, such as 404 Page Not Found
ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /servererror.html
The Bottom Line
We can deliver a complete web site for under $AU1,000
depending on how much help you need with the content.
|