반응형
http://blog.naver.com/orion_203?Redirect=Log&logNo=130038762874


일반 도메인에 www를 붙이는 방법.



1.VirtualHost 설정시 두가지를 다 해준다.

   ServerName 을 두가지로 해서 해준다.

   문제점: 에러로그나 액세스로그가 각각 작성되어 진다.(물론 둘다 같은파일을 지정하면 되긴 한다.)



2.VitualHost  에서 RedirectMatch를 이용한다.

아래와 같이


<VirtualHost 000.000.000.000>
    DocumentRoot /home/orion/tc
    ServerName memolog.pe.kr
    RedirectMatch /(.*)$ http://www.memolog.pe.kr/$1
</VirtualHost>

<VirtualHost 000.000.000.000>
    ServerAdmin webmaster@memolog.pe.kr
    DocumentRoot /home/orion/tc
    ServerName www.memolog.pe.kr
    ErrorLog /home/orion/orionerror_log
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common

        <Directory "/home/orion/tc">
                Options FollowSymLinks
                AllowOverride FileInfo
        </Directory>
</VirtualHost>



위와 같이 설정을 하면 memolog.pe.kr 접근했을때 www.memolog.pe.kr 로 리다이렉트 해준다.
[출처] 아파치 RedirectMatch 문법을 통한 자동으로 'www'붙이기.|작성자 님프

반응형

+ Recent posts