Hypertext Access file ( htaccess ) is the most common important file for allowing the designers and developers like to alter the configuration of the Apache Web Servers in order to provide extra functionalities.
.htaccess files create methods
First, you need to create the file ( like htaccess.txt /.htaccess files ) and you have to give the permissions of the file for 644. Then you have to add the default .htaccess codes to provide extra functions to redirect the files urls.
Hear I mention some default .htaccess Control Access to Files codes !
# Allowed the All files code
deny from all
#Allowed the All files code End
#301 Permanent Redirects code
Redirect 301 /olddirectory/file.html http://www.domainname.com/newdirectory/file.html
#301 Permanent Redirects code End#Set the Email Address for the Server Administrator
ServerSignature EMail
SetEnv SERVER_ADMIN [email protected]
#Set the Email Address for the Server Administrator End
#Detecting Tablets and Redirecting
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://yourdomain.com/folderfortablets [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*Android.*$
RewriteRule ^(.*)$ http://yourdomain.com/folderfortablets [R=301]
#Detecting Tablets and Redirecting code End
# Link Protection Code
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?domainname.com/ [nc]
RewriteRule .*.(gif|jpg|png)$ http://domainname.com/img/hotlink_f_o.png [nc]
# Link Protection Code End
# Rewrite URLs code
RewriteEngine on
RewriteRule ^content-([0-9]+).html$ content.php?id=$1
# Rewrite URLs code End
# Redirect Browser to https code
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# Redirect Browser to https code End
# Activate SSI Code
AddType text/html .html
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
AddHandler server-parsed .htm
# Activate SSI Code End
# Change the Charset and Language headers Code
AddDefaultCharset UTF-8
DefaultLanguage en-GB
# Change the Charset and Language headers Code End
# Block Unwanted Referrals Code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} website1.com [NC,OR]
RewriteCond %{HTTP_REFERER} website2.com [NC,OR]
RewriteRule .* - [F]
</ifModule>
# Block Unwanted Referrals Code End
# Block Access to a Comprehensive Range of Files Code
<Files privatefile.jpg>
order allow,deny
deny from all
</Files>
<FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ ">
Order Allow,Deny
Deny from all
</FilesMatch>
# Block Access to a Comprehensive Range of Files Code End
# Block Unwanted User Agents Code
<IfModule mod_rewrite.c>
SetEnvIfNoCase ^User-Agent$ .*(bot1|bot2|bot3|bot4|bot5|bot6|) HTTP_SAFE_BADBOT
SetEnvIfNoCase ^User-Agent$ .*(bot1|bot2|bot3|bot4|bot5|bot6|) HTTP_SAFE_BADBOT
Deny from env=HTTP_SAFE_BADBOT
</ifModule>
# Block Unwanted User Agents Code End # Wordpress default htaccess code
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# WordPress default htaccess code End
If anyone need for .htaccess code Quotations on your mind please Ask me questions . I will be give the brief descriptions to help you!.
Bookmarks