Using Apache and .htaccess

Today I will write some tricks that you can use with Apache’s .htaccess

Redirecting all except your IP. So you can develop the website or debug it.

ErrorDocument 403
Order deny,allow
Deny from all
Allow from YOUR-IP-HERE

How to setup a timezone for the server

SetEnv TZ Australia/Adelaide

How to force a file download

AddType application/octet-stream .avi .mp3 .wav .pdf

SEO friendly redirect to www. version of the website.

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^ [nc]
rewriterule ^(.*)$$1 [r=301,nc]

Where and you can replace it with your own site name.

Redirecting a single page [SEO Friendly]

Redirect 301 /old/page.html

Redirecting a whole directory [SEO Friendly]

RedirectMatch 301 /somefolder(.*)$1

For custom error pages with help of .htaccess refer to : Creating custom error pages for your site.

You Might Also Like