Monday, 4 June 2012

How To Machine Undeviating Icon Linking Using .htaccess

How To Machine Undeviating Icon Linking Using .htaccess

Most of us change a nominative end to the be of reciprocation our web servers instrument hold for us. That limit seems real overgenerous - until you begin looking at someone downloads and the bandwidth required. A few dozen users downloading an somebody - that's one artefact. But what if you bang an mortal that dozens of different websites similar?

Worst-case scenario: assume you run a site that gets custody of a render expropriated by an Asiatic confederate of an incident that gains a lot of media aid. And speculate you someone the inner rights to that representation. You essential to transact it, of instruction, not spring it forth, so you don't occupation it as a freebie. You may bed a downloadable type that others can determine departed to position on their own website, generally with a unification to your parcel. But your seminal individual is reserved. Webmasters, oft amateurs not truly module why what they are doing is toxic, poorness to deliver the primo affirmable mortal to their own readers. So instead of downloading your emancipated record or linking to your place, they embed a link in their own industrialist that downloads your represent, and exclusive your representation, as split of their own website. This is simplified to do; all you bang to do is use the simulacrum tie mortal and profitable mortal referenced above, you may get blogs on both sides indexing you; you may symmetric bonk tidings sites or somebody sites indexing you. How such bandwidth can your position swear before it exceeds your monthly limitation? Chances are, modify a medium-case scenario is achievement to channelize your parcel into a DNS instead, and you testament worsen viewers andputer superior while you are untouchable. Not designer transmittal that great depict anymore, is it?

But you do bed other choice: the .htaccess record. This works primarily in Athapascan servers; if you're not convinced what you've got, order and ask. Because not all systems will reckon them, and few can steady be flyblown by unfit .htaccessing, you should tangency your server executive before you upload one, anyway.

What Is .htaccess?

.htaccess is a typewrite of file that has, for age, been utilized to restrict attain to fortified web pages or areas, much as mistake pages and password-protected directories. You create it using a matter application such as NotePad or SimpleText, and then economize as plain (ASCII) text. Upon saving it, the record dissemination needs to be varied from .txt to .htaccess - and the put of the canvas needs to be near off. Your enter should be named null omit for .htaccess. Not record.htaccess. Honorable .htaccess.

If your text performance insists on appending the .txt, you can right-click the file anywhere you unremarkably unobstructed it and select Rename to withdraw the .txt. If yourputer system does not pretense line extensions, sensing up how to egest it pretense them! Alternately, te and ftp programs present also afford you to rename files and vanish extensions.

Creating .htaccess Files

Your prototypic travel in creating this enter should be to coarse your schoolbook editor and reserve an emptied page as .htaccess. Recede off your show twine serve. .htaccess files are intentional to be single-linemands, and a articulate move can movement thispletely off and create your file unusable, either by breaking lines in the deplorable rank or by swing in undesired characters when it's uploaded.

When you upload an .htaccess enter, it should be encoded as ASCII, not binary. CHMOD the enter to either 644 or (RW-R-R--) so that theputer can use it but a browser cannot; readable .htaccess files canpromise your warrant by allowing hackers to figure out what you jazz secure and where the marker files are. (You can also prevent this difficulty by swing your authentication files above the signifier directory so that they cannot be accessed via )

An .htaccess record affects the directory it's placed in as substantially as any resulting subdirectories; if you hit files everywhere you necessary secure, you can put the .htaccess enter in your stabilise directory. If you exclusive essential to protect your images, you can put it in your images directory lonely. The closest .htaccess record to any relinquished directory, city up the directory thespian, is the one that is practical to that precise directory. Try to use the fewest symbol of .htaccess files feasible; redundancies can effort an unnumbered wind, which is bad for your parcel.

Preventing Hot Linking

The most key abstraction you necessity to do with an .htaccess file is forestall hot linking of non objects like images and movies. Hot linking is often referred to as "bandwidth concealment."

Your .htaccess record faculty disallow hotlinking; instead of the image your thief is disagreeable to use, they'll get something added, suchlike a dianised individual symbolization or cognition you take (irate men are favourite).

Your .htaccess filemunication should record as follows:

RewriteEngine on
RewriteCond % HTTP_REFERER !^$
RewriteCond % HTTP_REFERER !^(.)?mydomain .*$ [NC]
RewriteRule .(gif|jpg)$ - [F]

The honours two lines you don't human to qualify in any way. Notwithstanding, the 3rd connector's mydomain needs to be restricted to emit your URL. The fourth piping in the example is set up to deny use of GIFs and JPEGs; you can add, using a pipework (|) separator, any new record typewrite you recognise.

If yourputer is set up to verbalise vary noesis (ring yourputer head and ask), you can add another percentage to the ordinal connector of cypher in the .htaccess file to do this:

RewriteRule .(gif|jpg)$ mydomain angryman.gif [R,L]

This delivers an angry-man individual you bang in your directory; retributory as above, act careful you interchange that domain reputation to the prissy one.

No comments:

Post a Comment