# vi /etc/httpd/conf/httpd.conf
(Cent OS의 경우)
맨하단에
<virtualhost *:80>
ServerName domain.com
ServerAlias *.domain.com
DocumentRoot "/home/root/public_html"
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.domain\.com(.*) /home/$1/public_html/$2
</virtualhost>
예를 들어 aaa.domain.com이라면
$1은 aaa
$2는 index.html이나 index.php
httpd.conf는 순차적으로 읽어오기때문에 가장 하단에 추가해야된다.
rewirite모듈로 하위도메인만들기
2014. 3. 12. 16:33