header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() + 300) . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
Hope this help :)
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() + 300) . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
RewriteEngine On
RewriteRule ^tutorials/(.*)/(.*).php /tutorials.php?req=tutorial&tut_id=$1&page=$2
Example #4:
The following will display contents in newpage.html when visitor browses to oldpage.html:
RewriteEngine on
RewriteRule ^oldpage.html$ /newpage.html
Example #5:
The following will rewrite the URL to http://yourdomain.com/directory/newpage.html when visitors browse to http://yourdomain.com/anypage.html
The following will display contents of http://yourdomain.com/folder1/folder2/folder3/index.php when visitors browse to http://yourdomain.com/folder1/index.php (while maintaining http://yourdomain.com/folder1/index.php in the address bar of the browser)
Example #6:
The following example will forward a visitor coming from a specified IP address (eg. 123.45.67.8) to another location (eg. /):
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^123.45.67.8$
RewriteRule ^.*$ - [F]
The following example will forward a visitor coming from a specified IP address (eg. 123.45.67.8) to another location (eg. /) if they try to access any .php files:
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^123.45.67.8$
RewriteRule .php$ - [F]
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^123.45.67.8$
RewriteRule ^(.*)$ http://www.yahoo.com [L]
Example #7:
Hot linking (ie. bandwidth stealing) happens when people link to files and images on a different server, display them on their website and the bandwidth is at the other website owner's expense. The following example can prevent hot linking to your website:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourdomain/.*$ [NC]
RewriteRule .(gif|jpg)$ http://yourdomain.com/image.gif [R,L]
Other Examples of .htaccess configurations:
Example #8:
If you have problems with certain visitors to your website, you can ban them. There are two different ways to ban visitors: (1) using their IP address they came from or (2) using the domain name which they came from.
The following example denies a visitor coming from IP address 123.45.67.8:
order allow,deny
deny from 123.45.67.8
allow from all
The following example denies visitors coming from a block of IP addresses coming from 123.45.67.0 to 123.45.67.255
order allow,deny
deny from 123.45.67.
allow from all
The following example denies a user by the domain name from which they came from:
order allow,deny
deny from www.theirdomain.com
allow from all
The following example denies a visitor from a domain name and all subdomains within the domain name:
order allow,deny
deny from .theirdomain.com
allow from all
The following example denies all visitors except your own IP address assigned to you by your ISP (Internet Service Provider):
Order deny,allow
Deny from all
Allow from youripaddress
Example #9:
Order allow,deny
Deny from 123.45.67.8
Satisfy All
The following example will allow all of files in .php extension to be accessed using .html or .htm extension:
RewriteEngine On