.htaccess Tricks / Directives

Lately I have been increasingly forced to use file .htaccess (File containing definitions Apache), or to filter IPSites (controlled access to a web page) or to set PHP flags.

1. The first thing a person who is interested in working on an online project directly on the server and does not want the site can be accessed by other users besides him is filtering IPs. The file. Htaccess will be written the following lines:

order deny, allow
deny from all
allow from 83.23.2.4

Thereby Directive blocked access to all users (), Less 83.23.2.4. If work on localhost (with Apache installed) and the webserver site-ul/fisierele want to be visible only in LAN (Local Area Network), use:

order deny, allow
deny from all
allow from 192.168.0.0 / 24

2. Blocking access to certain IP-uri/domenii webserver.

POST GET <limit PUT>
order deny, allow
deny from 66.57.12.48
deny from. isp.com
allow from all
</ Limit>

- Not allowed access to the webserver IP and domain 66.57.12.48 * .isp.com.

3. Disable Directory Browsing.

Options All-Indexes

Specifically, we prohibit access to folders without index (Index of /).

4. Changing the default index. (Default page)

DirectoryIndex index.php index.html home.html

A webserver set default index.html and index.php files will index / home. However, if you want a web address to appear as a readme.txt file index in. Htaccess is written "DirectoryIndex readme.txt".

5. Blocking referrer sites.

RewriteEngine on
RewriteCont% {HTTP_REFERER} site-blocat.com [NC] RewriteCond% {HTTP_REFERER} blocked site-2.com [NC] RewriteRule. * - [F]

If you have a link of your site on other web pages that do not wish to receive visors, you can use the lines above.

6. Block "hot link" to avoid theft traffic (bandwidth).

RewriteEngine on
RewriteCond% {HTTP_REFERER}! ^ $
RewriteCoun% {HTTP_REFERER}! ^ Http: // (www.)? Domain-meu.com /.*$ [NC] RewriteRule. (Gif | jpg) $ - [F]

Prohibit another site to use images (jpg and gif) that are hosted on the server.

7. Flags of PHP change. Htaccess

To be more safe, some servers are set register_globals OffHowever, there are scripts (Joomla si MamboFor example) that require the installation register_globals On. If you use a file sharehosting and do not have access php.iniYou can use. Htaccess to change php_flags.

php_flag register_globals On

.htaccess

More definitions for settings of. Htaccess,

.htaccess Tricks / Directives

About the author

Stealth

Passionate about everything that means gadgets and IT, I write with pleasure stealthsettings.com from 2006 and I like to discover with you new things about computers and operating systems macOS, Linux, Windows, iOS and Android.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment is processed.