Latest News
Đẩy log exception của spring boot lên elasticsearch
  • About
  • EmEditor
  • Register Google Adsense

Love Coding

Note anything I want

  • Home
  • Web Development
    • HTML
    • Javascript
    • jQuery
    • CSS
    • PHP
    • ASP
    • JSP
    • Fix Bug
  • Other Development
    • Desktop Java
    • Mobile J2ME
    • VBS
  • Operating System
    • Windows
    • Linux
  • Database
    • MySQL
    • Oracle
  • Software
Home » PHP » Love Coding: Order allow,deny example

Order allow,deny example

HuyPV
Add Comment
PHP
Monday, June 28, 2010
Order allow,deny example

Order allow,deny can be quite confusing, so let's take a look at a few examples. First, we provide a few examples related to the Allow directive alone without the Order of the Order allow,deny directive.

Example: Allow from example.com

All hosts from this domain will be allowed, for example abc.example.com as well as www.example.com. Host from www.abcexample.com would not be allowed.

Example: Allow from 10.1.2.3
Example: Allow from 10.1

You can define the access level also by providing the IP address. In the first example, just the host with just that IP address would be allowed access. In the second example, all hosts from all subnets within 10.1.x.x would be allowed access.

The Deny directive works the same way. Now that we know how Allow and Deny works, let's take a look at how Order allow,deny works.

<Directory "/www">
Order Allow,Deny
Deny from all
Allow from all
</Directory>

In this case, your client would be denied access. Why? Because Apache first evaluates the Allow directive rules and then the Deny directive rules, so Allow from all would be executed first and then the Deny from all would take place.

Now the same example with the Order allow,deny swapped.

<Directory "/www">
Order Deny,Allow
Deny from all
Allow from all
</Directory>

The configuration above would result in your client being allowed access because the Deny from all rule would be processed first and the Allow from all rule would be processed second. Now, let's get more specific. The following example could be used for specialized and restricted servers, for example some kind of intranet site.

<Directory "/www">
Order Deny,Allow
Deny from all
Allow from example.com
</Directory>

This is a bit expanded application of the Order directive. This configuration would restrict everyone from accessing the /www directory but hosts in the example.com domain. Abc.example.com would be allowed access, www.myexample.com would be restricted. Now, let's say you want to do the opposite. You want to restrict someone from some specific domain (perhaps someone who is attacking your web site) and allow everyone else.

<Directory "/www">
Order Allow,Deny
Allow from all
Deny from www.myexample.com
</Directory>

The configuration provided above would give access to everyone and restrict all hosts from the www.myexample.com domain.

Now, what happens if you forget to provide specific rules and use just the Order allow,deny directive alone?

<Directory /www>
Order Allow,Deny
</Directory>

The presence of an Order directive can affect access to a part of the server even in the absence of accompanying Allow and Deny directives. That is because when you specify the Order allow,deny you also control the default access state. The example above will Deny all access to the /www directory because the default access state is set to Deny.
Tweet
Order allow,deny example Title: Order allow,deny example
Description: Order allow,deny example Order allow,deny can be quite confusing, so let's take a look at a few examples. First, we provide a few exam... ...
Rating: 4

No comments :

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments ( Atom )
Quảng cáo

Popular Posts

  • mysql_error: Undeclared variable: INF
    mysql_error: Undeclared variable: INF PHP Code: $limit = 10; $page = isset($_GET['p']) ? $_GET['p'] : 1; $offset = ($pa...
  • Check Laravel version
    Đối tác bảo đang code và dùng Laravel, giờ muốn biết version Laravel tương ứng là bao nhiêu để xem mà code theo. Làm sao check? Cách 1: Sử...
  • VBS - Upload file HTTP Post
    Source: http://www.ericphelps.com/scripting/samples/Reference/Web/HTTP_POST.txt   Sub Upload(strUploadUrl, strFilePath, strFileField, strD...
  • Add other collapse div to your forum
    Collapse <div style="height: 16px; padding-right: 4px; font-weight: bold;" class="blockhead"> <span style=...
  • Trong laravel thì queue:work với queue:listen khác nhau thế nào?
    Trong laravel thì queue:work với queue:listen đều chạy jobs trong queue. Vậy 2 cái này cũng phải có gì đó khác nhau chứ, nếu ko thì nó là ...
  • Hàm chuyển từ ngày dương lịch sang âm lịch (PHP)
    <?php function INT($d) {     return floor($d); } function jdFromDate($dd, $mm, $yy) {     $a = INT((14 - $mm) / 12);     $y = $yy + 4800 ...
  • Use the YouTube API with PHP
    Process and integrate data from YouTube into your PHP application with PHP's SimpleXML extension Summary:   The YouTube vide...
  • Character Set và Collation trong MySQL là gì? Tạo DB thì để UTF8_GENERAL_CI hay UTF8_BIN
    Character Set là một tập các ký tự và dạng số hóa của các ký tự đó Collation là một tập các luật để so sánh các xâu được sinh ra từ các ký ...
  • git checkout file from other branch
    Đang làm trên nhánh dev. Muốn lấy 1 file, ví dụ: xxx/helper.php ở trên nhánh master về dev thì làm thế nào? Cách 1: nông dân nhiều bước nh...
  • Download media files (video, audio) from VnExpress.Net
    Download media files (video, audio) from VnExpress.Net Example: http://vnexpress.net/GL/Vi-tinh/Giai-tri/2010/02/3BA18A0E/page_4.asp htt...
Back to top!
Copyright 2010 Love Coding - All Rights Reserved Design by Newbie_PC - Powered by Blogger