How To Create & Edit The .htaccess File

.htaccess is the default name of a configuration file that contains server directives that tell the server how to behave. One common use for an htaccess file is to restrict access to specific files or directories on the Internet, or to specify a particular webpage to be accessed when the file requested by the browser is not found (error 404). The .htaccess file usually resides in the root public_html directory of your server.

.htaccess Examples

# Disable directory browsing
Options All -Indexes

# Redirect a single page
Redirect 301 /oldpage.html http://www.example.com/newpage.html

# Redirect from old domain to new domain
RewriteEngine On
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]

# Custom Error Pages
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

# Prevent access throughout the afternoon
RewriteEngine On
RewriteCond %{TIME_HOUR} ^12|13|14|15$
RewriteRule ^.*$ - [F,L]

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

# Just allow my IP to access
order deny,allow
deny from all
allow from xxx.xx.x.xxx

# Deny visitors by IP address
order allow,deny
deny from 111.111.111.111
deny from 123.123.123.
allow from all

# Deny all IPs except mine and redirect
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^12\.12\.12\.12
RewriteRule .* http://www.redirecturl.com [R=302,L]

 

WHAT IS PAGERANK?

  • Page Rank (PR) is a quantity defined by Google that provides a rough estimate of the overall importance of a web page. If a web page has a lot of links from large websites that also rank well, then the original web page is given a high ranking.

    A hyperlink to a page counts as a vote of support. The PageRank of a page is defined recursively and depends on the number and PageRank metric of all pages that link to it ("incoming links"). A page that is linked to by many pages with high PageRank receives a high rank itself.

WHAT ARE BACKLINKS?

  • Backlinks, which are sometimes called inbound links, are incoming links to a web page or the entire website. These inbound links are important to search engine rankings because many different search engines have algorithms that measure the number of backlinks a website or web page has, and ranks those web pages with more backlinks in a higher position.