메뉴 건너뛰기

조회 수 7647 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄


List of methods used to redirect a web site using Apache:
Web site forwarding and redirection methods:
  1. One can forward a web page URL or home page using the following web page with the "Refresh" directive:
    <META HTTP-EQUIV="Refresh" Content="0; URL=http://www.company.com/dir1/">
    This commands the browser to refresh the page with the new specified URL. This forwards a single page only and not the entire domain. It can forward the default home page for the domain giving the appearance of forwarding the domain.. or:
    <html>
    <head>
    <META HTTP-EQUIV="Refresh" Content="3; URL=http://www.company.com/dir1/">
    </head>
    <body>
    This page will forward to http://www.company.com/dir1/ in three seconds.
    <p>
    Please update your links.
    </body>
    </html>

  2. Use a CGI script to forward a home page: (mod_cgi)
    File: httpd.conf
    ScriptAlias / /var/www/cgi-bin/redirect-script/
    File: /var/www/cgi-bin/redirect-script
    #!/usr/bin/perl
    
    print "Status: 301 Moved\r\n" .
          "Location: http://www.new-domain.com/\r\n" .
          "\r\n";
                        
    or:
    #!/usr/bin/perl -w
    use strict;
    use CGI qw/:standard/;
    print redirect('http://www.new-domain.com');
                        

  3. Use a PHP script to redirect:
    <?php
    header("Location: http://www.new-domain.com/");
    ?>
                        
  4. Use a Javascript to redirect:
    <html>
    <head>
    <script language="Javascript" type="text/javascript">
    <!-- Hide script
    //<![CDATA[
    window.location.href="http://www.new-domain.com/"	    
    //]]> End script hiding -->
    </script>
    </head>
    </html>
                        
  5. Use Apache module (mod_rewrite)
    File: httpd.conf
    RewriteEngine On
    RewriteRule /.* http://www.new-domain.com/ [R]
    Forwards all references in entire domain.

  6. Use Apache module (mod_alias )
    File: httpd.conf
    • Redirect Domain:
      Redirect / http://www.new-domain.com/
      or
      Redirect permanent / http://www.new-domain.com/
    • Redirect Page:
      Redirect /web-page.html http://www.new-domain.com/destination-web-page.html
                              
    Note:
    • Redirect directives take precedence over Alias and ScriptAlias directives.
    • Other "Redirect" options include: temp (error 302) default - temporary redirect status, seeother (error 303) resource has been replaced and gone (error 410) resource has been permanently removed.
    Example httpd.conf with virtual hosts for multiple domains which all redirect:
    <VirtualHost XXX.XXX.XXX.XXX>
    ServerName directtolinux.com
    ServerAlias www.directtolinux.com
    ServerAlias direct-to-linux.com
    ServerAlias www.direct-to-linux.com
    ServerAlias digitalpenguins.com
    ServerAlias www.digitalpenguins.com
    Redirect permanent / http://www.yolinux.com/
    </VirtualHost>
                            


  7. Apache 301 redirect using the .htaccess file:
    If one wants to permanently forward an entire web site to a new URL or forward a single page permanently and have the search engines update their database, one should use a 301 redirect. This may redirect to a new server or to itself but to a different domain. This tutorial shows how. This method is a variation of using the mod_alias redirection shown above except that it allows the customer to redirect themselves by providing a .htaccess file themselves.
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yolinux.com
    RewriteRule ^(.*)$ http://www.yolinux.com/$1 [R=permanent,L]
    This example forwards http://yolinux.com to http://www.yolinux.com/ to unify your site to a single URL. This can also simplify your web logs if they can not distinguish between the two


List of Articles
번호 제목 날짜 조회 수
236 & 실행과 nohup 실행 2017.04.18 7837
235 AIDE를 이용한 리눅스 파일 시스템의 무결성 점검 2014.03.26 8542
234 apache + mysql 자동 실행 방법 (소스설치) 2014.02.27 7966
233 Apache 2.2.17 + WebLogic 10.3.3 연동하기 2016.11.22 8792
232 Apache 2.x 에서 maxclients 1024 제한 초과 방법 (수정 중..) 2016.03.18 8554
231 Apache Mod_Security 사용방법 2016.04.22 8912
230 apache status 모듈 ( 모니터링 ) 2014.02.27 8493
229 apache vhost deny 설정 2014.03.26 7583
228 apache 구동중지되어있을 때 재구동 스크립트 2016.03.18 7373
227 Apache 동시접속자수 확인 2019.02.14 1906
226 apache 로그정리 (logrotate) 2014.02.27 7434
225 Apache 리다이렉트 2016.03.18 8155
224 Apache 웹서버 server-status 모니터링 file 2014.03.26 6954
223 Apache 웹서버 server-status 모니터링 2014.02.27 8074
222 apache 컴파일시 동시 접속자 제한 변경하기 2014.03.26 8155
221 Apache 환경 설정 파일 정보 (httpd.conf) 2016.09.19 7472
» Apache(아파치)를 사용해 redirect(리다이렉트) 하는 방법 7 2014.02.27 7647
219 apache, mod_ssl 설치 (apache 1.3.37버전) 2014.02.27 7660
218 APACHE, OHS 400 웹로직 연동후 특정 작업에 400 error 2016.12.30 8630
217 apache2 트래픽 모듈 mod_cband 사용법 2019.02.14 1129
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 12 Next
/ 12

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved