M

Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration, referer 본문

PHP

Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration, referer

M_master 2025. 9. 18. 14:29

버전 : Apache 2.4 이상

 

원인 : Apache 2.2까지 지원 (Order, Allow, Deny)

 

.htaccess에서 Order 지시어가 있어서 문제 발생

> 만약 열어본 파일에 Order 지시어가 없다면 상위 폴더에서도 .htaccess 파일도 순차적으로 읽어서 오류 발생

 

httpd.conf에서 주석 해제 (예전 방식을 쓰는 방법)

> LoadModule access_compat_module modules/mod_access_compat.so

 

Apache 2.2 방식

<Directory "C:/apm/Apache24/htdocs">
    Order deny,allow
    Deny from all
</Directory>

 

Apache 2.4 방식

<Directory "C:/apm/Apache24/htdocs">
    Require all denied
</Directory>

 

아래처럼 변경

Deny from all → Require all denied
Allow from all → Require all granted
Allow from 192.168.0.10 → Require ip 192.168.0.10
Allow from 192.168.0.0/24 → Require ip 192.168.0.0/24

 

(Order, Allow, Deny) 설명

 

- 허용 (Allow)과 차단 (Deny)을 어떤 순서로 처리할지를 지정

(즉, 같은 IP나 조건이 Allow와 Deny에 동시에 걸리면, Order에서 지정한 순서대로 처리)

- 기본적으로 두 가지 방식이 존재

  • Order allow,deny : Allow 먼저 적용 후 Deny 적용
  • Order deny,allow : Deny 먼저 적용 후 Allow 적용

1. Allow

Allow from 192.168.0.100
Allow from 127.0.0.1

 

특정 호스트, 도메인, IP 주소, 네트워크 대역에서의 접근을 허용

예시

  • Allow from all : 모든 접근 허용
  • Allow from 192.168.0.0/24 : 192.168.0.* 대역 허용

2. Deny

Deny from all
Deny from evil.com
Deny from 10.0.0.0/8

 

특정 호스트, 도메인, IP 주소, 네트워크 대역에서의 접근을 차단

예시

  • Deny from all : 모든 접근 차단
  • Deny from 123.45.67.89 : 특정 IP 차단

모두 차단

Order allow,deny
Deny from all

 

모두 허용

Order deny,allow
Allow from all

 

기본 차단, 특정 IP만 허용

Order deny,allow
Deny from all
Allow from 192.168.0.10
728x90