I. What is .htaccess?

.htaccess is a special configuration file, .htaccess allows you to change the behavior of the Apache server directory floor. .htaccess File includes the command line, can be customized according to users, are placed in a certain folder and it will work for that folder and all subfolders in the folder. One common application of .htaccess is allowed to rewrite URLs

II. The special symbols in .htaccess.

To be able to understand and use the .htaccess customers need to know the meaning of the special symbols in .htaccess below:

[F]

Forbidden: This character is used to specify the server will return a 403 error page if the client access to places not allowed

[L]

Last rule: This character to determine that the previous steps have been completed, stop and not continue to execute the next command again rewritten.

[N]

Next: instructs the server continues to rewrite until all items specified completely rewritten.

[G]

Gone: Specify a client server returns the error page does not exist (no longer exit)

[P]

Proxy server specified condition requirements set by mod_proxy

[C]

Chain: Specifies the current server implementation rule parallel with the previous rule

[R]

Redirect: Redirect request a specific server to another page where browsers send requests to browse a page that is corrected path (rewritten) before.

[NC]

No-case: Specifies server math but similar characters, for example, the following command: 

RewriteCond% {HTTP_REFERER}! ^ Http: //domain.com/.*$ [NC]

Then the word is domain.com or Domain.com or DoMain.com ... are match.

[PT]

Pass through means using characters to force "rewrite engine" set table uri value becomes the value of name files

[OR]

This may be called an operator, the expression is contiguous with the OR, including proper expression, would be rules to apply Rewrite command.

[T = MIME-type]: Mime Type allows website access multiple file formats.

[]: Define a set of characters in which any character in the brackets appear to be match.

[] +: Set of characters in which any association with it was match.

[Az] matches all characters from az, alphabetically. There could be more: [a-zA-Z].

{n} a: determine the number of characters will be extended with the first character, ie when the match was the first character will take, how much extra the next character. Example: x {3} will take: x's, xad, ...

a {n,} {n} but as a can take 3 or more.

a {n, m} {n} but as a will take between n to m.

(): Groups of characters together, see them as one single unit.

^: Notes begin regex string.

$: Notes ending a regex.

? : Allows selection of up tu.Vi example monzas? will match the Monza or monzas.

! : Describes a negative, will match with all other things with the following characters!

. : Expression for any single character.

+: Match with one or more characters.

*: Matches 0 or more characters.

| : Allows or logic.

 

\: Add prior to the special character to be able to use them as normal characters.

. *: No character or multiple characters any.

^ $: Define an empty string.

^. * $: Used to match everything.

Some error codes:

401 - Authorization Required: Error unauthenticated user and password

400 - Bad request: Error accessing invalid, because the server does not accept the request, or the request lacks a certain number of requirements.

403 - Forbidden: Error accessing banned sites

500 - Internal Server Error: Error from server

404 - Wrong page: Error accessing the page does not exist

301 - Moved Permanently: 302 - Moved temporarily: Error accessing the page has been moved

III. Basic features of .htaccess.

1.Against stealing resources and bandwidth.

This feature can help customers proactively in sharing documents and photos on other websites, in order to avoid wasting bandwidth can add the following to your .htaccess file:

RewriteEngine on

RewriteBase /

RewriteCond% {HTTP_REFERER}! ^ $

RewriteCond% {HTTP_REFERER}! ^ Http: // (www \.)? Yourdomain.com /.*$ [NC]

RewriteRule. * - [F]

Customers can add the site to share documents, photos or web pages only to their customers by adding a line RewriteCond% {HTTP_REFERER}! ^ Http: // (www \.)? Yourdomain.com/ . * $ [NC] and fix "yourdomain.com" into customer domain to share.

2. Against Ip access 

Customers can configure block ip or domain by adding the following line to your .htaccess file:

<Limit GET POST PUT>

order allow, deny

Allow from all

deny from x.y.z.v

deny from. * domain \ .com. *

</ Limit>

Customers can add the IP or domain you want to block by adding lines or deny from xyzv deny from. * Domain \ .com. * Which xyzv is ip and domain.com is the domain name you want to block.

3. Redirect configuration in .htaccess

Customers can configure the switch by adding the following line to your .htaccess file:

- For the redirection file to add the following customers:

301 redirect /old/old.htm http://yourdomain.com/new.htm

For example, on the client redirects old.html file located in the folder to the path http://yourdomain.com/new.htm old with error 301 is permanently moved.

- For switching the entire website to a new domain name customers added as follows:

RewriteEngine on

RewriteCond% {HTTP_HOST} ^ example.com $ [NC, OR]

RewriteCond% {HTTP_HOST} ^ www.example.com $ [NC]

RewriteRule ^ (. *) $ Http://example.net/$1 [L, R = 301, NC]

Was this answer helpful? 5 Users Found This Useful (6 Votes)

Powered by WHMCompleteSolution