Tuesday, March 07, 2006

.htaccess Tutorial

 

If you don't know how to make an .htaccess file, just open up your text
editor and insert these codes, then save it as .htaccess. I am not
responsible if these scripts don't work on your server and you get some sort
of error. If that happens, just make another .htaccess file that is
completely blank. These are all the scripts I use in my .htaccess files.
Enjoy.

--------------------------------------------------------------------------------
This script is used if you don't want people to be able to browse through a
certain directory.

IndexIgnore *
--------------------------------------------------------------------------------
This script is used so that no one can view your .htaccess script (very
useful!).

<Files .htaccess>
order allow,deny
deny from all
</Files>

--------------------------------------------------------------------------------
This is a script that will allow you to change the location of the index
file.

Redirect /olddirectory/oldfile.html
http://yoursite.com/newdirectory/newfile.html

--------------------------------------------------------------------------------
This is a script that will redirect IP's that you don't want viewing your
site. (I set up an account on geocities for this script so that people would
know they had been blocked and why.)

RewriteEngine on
RewriteCond %{REMOTE_ADDR} 00\.00\.00\.
RewriteRule .* http://www.youralternativedirectory/yourwarningpage.htm [R]

*Remember to change the IP address (00\.00\.00\.) to whatever IP you are
blocking, but keep it in the same format! Also, change the URL to the
directory (not a directory on your site) that you can link to to warn them
that they have been blocked.
--------------------------------------------------------------------------------
To block referrals from a specific domain.

SetEnvIfNoCase Referer "^http://www.thatdomain.com/" BadReferrer
order deny,allow
deny from env=BadReferrer

*Remember to change the URL to the URL you wish to block.
--------------------------------------------------------------------------------
This script will not allow people to direct link your files. (You can change
these files to whatever you wish, but be sure to separate your images into
different directories before you do this if you are planning on direct
linking any of them; a good example is if you have a webcam, you'll still
want people to direct those images, but not images that are in other
directories. If you put this in the main part of your site, it will block
all access to those files, so be sure to put it in sub-directories.) This
script will direct whoever is trying to direct-link your images to another
image that is embarrassing.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(jpg|gif|js|css)$
http://www.yourdomain.com//images/youralternativeimage.jpg [R,L]

--------------------------------------------------------------------------------
You can use this if you don't want to let people direct link your images,
but you don't want to insert an embarrassing image.

RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER}
!^http://(www\.)?yourdomain.com/.*$ [NC] RewriteRule \.(gif|jpg)$ - [F]

--------------------------------------------------------------------------------
An example of all these together in an .htaccess file would be:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(jpg|gif|js|css)$
http://www.yourdomain.com//images/youralternativeimage.jpg [R,L]

SetEnvIfNoCase Referer "^http://www.thatdomain.com/" BadReferrer
order deny,allow
deny from env=BadReferrer

IndexIgnore *

--------------------------------------------------------------------------------
Just remember to double-space between the scripts and everything should work
fine. If some of these scripts just don't work for you, go to Google.Com and
look up .htaccess scripts because there are many ways to do one thing in
.htaccess and not all servers accept the same scripts.


  posted by Smile Community @ 6:11 PM

0 Comments:

Post a Comment

<< Home

 

Search


Web W-master

Home

Previous Post

*15 Tips to Drive Traffic to Your Blog

*Trick for improve search engine page relevancy.

*Double Your Adsense Revenue

*A Smart Trick for Attracting Higher Paying AdSense...

*Maximize Revenue with AdSense

*Search Engine Optimization some Mistakes

*Free directory submission links :

*Free web submission links :

*Free web templates links :

*Free web hosting links :

Archives

*February 2006

*March 2006

*April 2006

*May 2006

*August 2006

*September 2006

*October 2006

*November 2006

*December 2006

Partner Links

Best Offers

RSS Feeds

TOP Blog Links

BlogOmg >> The Best and Most Popular Blogs
Ping Your Blog!
Name:
URL:
Powered By: PingTheEmpire.com