Apache HTTP Server Version 2.5

�� 문��� mod_rewrite
참조 문ì��ë¥� ë³´ì¶©�©ë����.
mod_rewriteë¥� �¬ì�©í���� �����¼ë� 구ì�±ë��
ê°��� �¸ì�¤í�¸ë�� ë§����� ë°©ë��� �¤ë��©ë����.
mod_rewrite�� ë³´í�� ê°��� �¸ì�¤í�¸ë��
구���� ����� 방�� ��������. mod_rewrite�� ��존�� ����
먼ì�� ������ ê³��¤í�´ì�� �©ë����.
"mod_rewriteë¥� �¼í���� ë°©ë�"
문��� 참조��������.
���� �¸ì�¤í�¸ë��� ���� ê°��� �¸ì�¤í��
mod_rewrite�
�¬ì�©í�� ���� ê°��� �¸ì�¤í��
ë³����� ê°��� �¸ì�¤í�� �¤ì�� ���� �¬ì����ë¡��� VirtualHost �¹ì���� ë§��¤ì� ��ê³� ��ë©��¸ì���� �´ì������ 모ë�� �¸ì�¤í�¸ë��� ���� �����¼ë� ê°��� �¸ì�¤í�¸ë�� ë§��¤ê��� �©ë����.
�� �����¼ì������ ê°� �¬ì�©ì���� ���� �¸ì�¤í�¸ë�
SITE.example.com�� �¬ì�©í��ê³�
/home/SITE/www���� �����
��ê³µí���¤ê� ê°����©ë����. ê·¸ë�¬ë��
www.example.com�� �� 매í������ ���¸í��ê³���
�©ë����.
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]+)\.example\.com$
RewriteRule ^(.*) /home/%1/www$1
�´ë� tolower RewriteMap ì§����´ë�� �¬ì�©ë����
�¸ì�¤í�¸ë��� 모ë�� ��문ì���¸ì� ���¸í���� ���±í�´ì�� ���� ������ë¦�
구조�� 모í�¸í�¨ì�� ����ë¡� �©ë����.
RewriteCond����
�¬ì�©ë�� ê´��¸ë�� ��참조 %1, %2 �±ì�¼ë�
캡���, RewriteRule����
�¬ì�©ë�� ê´��¸ë�� ��참조 $1, $2 �±ì�¼ë�
캡ì��©ë����.
ì²� ë²�ì§� RewriteCond�� �¸ì�¤í�¸ë���
www.ë¡� ��������ì§� ���¸í��ê³�, ê·¸ë���¤ë©´ �¬ì���±ì��
ê±´ë���°ì�´ì�����.
�� 문ì������ �¼ì���� ë§��� 기ì��ê³� ë§�ì°¬ê�ì§�ë¡�,
mod_rewrite�� �¤ì��ë¡� �� ������ ��������
����� 방�� ��������. ���� mod_vhost_alias
�¬ì�©ì�� ê³��¤í�´ì�� �©ë����. �� 모ë���� ���� ì½���ì¸��� Alias
�´ì�� �� ���� ���� ��ê³� �´ì���� 모ë�� ê²��� �¨ì�� �� �°ì����ê²�
�리����.
mod_rewrite�
�¬ì�©í�� ���� ê°��� �¸ì�¤í�� ¶httpd.conf������ �� ë°�ì·���
ì²� ë²�ì§� ������ ���¼í�� ������
�����©ë����. ��ë°�ë¶��� ���� �´ë�� ë¶�ë¶�ê³� 매ì�� ���¬í��ì§�ë§�
���� �¸í���±ì�� ���� 그리ê³� mod_rewrite
ë¶�ë¶��� �¬ë�르ê� ��������ë¡� ������ �¼ë� ë³�ê²½ì�� ���µë����.
��ë°�ë¶��� �¤ì�� ������ ��������ë¡�
mod_rewrite� 구�����.
mod_rewrite�� �¤ë¥¸ URI ë³��� 모ë��(��:
mod_alias) ���� �¤í����ë¯�ë¡�,
mod_rewrite��� 그�� 모��� �리���
URL�� ëª������¼ë� 무ì������ë¡� ì§����´ì�� �©ë����. ���� ��
ê·�ì¹��� ScriptAlias ì§����´ë�� �°í����ë¯�ë¡�
mod_rewriteê°� �´ë�¬í�� 매í���� ëª������¼ë�
��������ë¡� �´ì�� �©ë����.
# get the server name from the Host: header
UseCanonicalName Off
# splittable logs
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
CustomLog "logs/access_log" vcommon
<Directory "/www/hosts">
# ExecCGI is needed here because we can't force
# CGI execution in the way that ScriptAlias does
Options FollowSymLinks ExecCGI
</Directory>
RewriteEngine On
# a ServerName derived from a Host: header may be any case at all
RewriteMap lowercase "int:tolower"
## deal with normal documents first:
# allow Alias /icons/ to work - repeat for other aliases
RewriteCond "%{REQUEST_URI}" "!^/icons/"
# allow CGIs to work
RewriteCond "%{REQUEST_URI}" "!^/cgi-bin/"
# do the magic
RewriteRule "^/(.*)$" "/www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1"
## and now deal with CGIs - we have to force a handler
RewriteCond "%{REQUEST_URI}" "^/cgi-bin/"
RewriteRule "^/(.*)$" "/www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1" [H=cgi-script]
�� 배�� �� �� mod_rewrite 기��
�¬ì�©í���� ë³����� �¤ì�� ���¼ì���� ê°��� �¸ì�¤í�¸ì���� 문ì��
루í�¸ë��� ë³����� �����©ë����. �´ë�� �� ë§��� ���°ì�±ì��
��ê³µí��ì§�ë§� �� ë³µì�¡í�� �¤ì���� �����©ë����.
vhost.map ���¼ì�� �¤ì��ê³� ê°��� �����¬ì��
�©ë����:
customer-1.example.com /www/customers/1
customer-2.example.com /www/customers/2
# ...
customer-N.example.com /www/customers/N
httpd.conf���� �¤ì���� �¬í�¨ë���´ì��
�©ë����:
RewriteEngine on
RewriteMap lowercase "int:tolower"
# define the map file
RewriteMap vhost "txt:/www/conf/vhost.map"
# deal with aliases as above
RewriteCond "%{REQUEST_URI}" "!^/icons/"
RewriteCond "%{REQUEST_URI}" "!^/cgi-bin/"
RewriteCond "${lowercase:%{SERVER_NAME}}" "^(.+)$"
# this does the file-based remap
RewriteCond "${vhost:%1}" "^(/.*)$"
RewriteRule "^/(.*)$" "%1/docs/$1"
RewriteCond "%{REQUEST_URI}" "^/cgi-bin/"
RewriteCond "${lowercase:%{SERVER_NAME}}" "^(.+)$"
RewriteCond "${vhost:%1}" "^(/.*)$"
RewriteRule "^/cgi-bin/(.*)$" "%1/cgi-bin/$1" [H=cgi-script]