“NO Hotlink” – Protect your website from hotlinking with htaccess

January 6, 2008

If you have a website running on Apache and Linux System, you can disable hotlinks.

Hotlinking is when a website or blog use your image with a direct link, so result a consuption of your website bandwith. I assume that I’ve posted a photo of 2MB on my blog and people use it on their webpage without reuploading my photo on their host. Posted Photo was viewed 200 times in 1 hour and consume 400mb of traffic only in 1 hour!! In a day became 9.6 GB of traffic and for website that hosted this photo not is good. Also, there are other many reasons to block hotlinking but this article would be only a solution to prevent hotlinking.

First of all you have to upload one image called no_hotlink.gif on your images directory of your website. (this image is attached below)

No Hotlink

(more…)

Apache – Alias Configuration with ServerAlias

December 13, 2007

What is Alias?

Alias is an alternative name to delivery a domain name. For example we have www.smokinglinux.com domain name configured correctly in our apache configuration files and we want other domains linking directly on our master domain or subdomains linking on www.smokinglinux.com. To know better this tutorial you have to see a configuration sample attached below:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
ServerName www.smokinglinux.com
ServerAlias smokinglinux.com web.smokinglinux.com
DocumentRoot /var/www/smokinglinux.com
</VirtualHost>

(more…)

PHP – Simple authentication script with PHP_AUTH_USER and PHP_AUTH_PW

November 18, 2007

In this howto, we can create a little PHP authentication system with only few rows of PHP code. We can use header() function to submit the “Authentication Required” Message to the client browser, so on client browser we can see a dialog popup that require Username and Password. When we fill the fields, we can receive variables through arrays: “$_SERVER: PHP_AUTH_USER” and “$_SERVER: PHP_AUTH_PW”. We can use this simple authentication system only if PHP runtime is installed as Apache module.

Now we can see how it works through the source code:

(more…)

Fast installing a Apache Webserver + MySQL Database Server + PHP on Debian

November 7, 2007

Install needed packages

First of all install all the needing packages:

apt-get install mysql-server apache2 php5 libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql

Create a password for the MySQL User root.

mysqladmin -u root password OWNPW

(more…)