메뉴 건너뛰기

조회 수 7667 추천 수 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
번호 제목 날짜 조회 수
157 대용량 HDD 파티셔닝(Mass storage Partitioning) 2014.02.27 7352
156 다중명령어(세미콜론(;), 파이프pipe(|), 더블 엔퍼센트 &&, ||)의미,사용법과 차이점 file 2023.01.12 158
155 긴급 스왑 메모리 추가 하기 2014.03.26 7622
154 기본 허가권,퍼미션 지정(제어, 설정)하기(umask와 작동 원리) file 2023.01.12 164
153 [Linux]리눅스,사용자계정(관련 파일,명령어) file 2015.11.21 8159
152 [CentOS 7] SSH 무작위 로그인 시도 막기 ( Fail2Ban ) 2018.03.28 69709
151 [CentOS 6.5] Virtual Box를 이용한 CentOS 6.5 설치 file 2017.03.11 6600
150 [CentOS 6.5] Tomcat 설치 및 구동 file 2017.03.11 9483
149 [CentOS 6.5] SSH,TELNET, FTP 설치 및 운용 file 2017.03.11 8561
148 [CentOS 6.5] JDK (JAVA) 설치 file 2017.03.11 8692
147 [apache] - .htaccess 설정 2016.03.18 7262
146 ZendOptimizer 3.3.9 설치하기 2014.03.26 7052
145 yum으로 phpmyadmin 설치 2014.03.26 7544
144 Yum과 rpm을 이용하여 PHP5.5버전 설치 2016.03.18 8075
143 yum-fastestmirror로 CentOS 5.0 의 yum 속도 업! 2016.03.18 7513
142 yum 업데이트 시 특정 패키지 예외처리 2016.03.18 8350
141 yum 업데이트 빠르게 하기 (yum-fastestmirror 플러그인 2014.02.27 7749
140 yum rpmforge 등록하기 2014.02.27 7806
139 yum (Yellowdog Updater Modified) 명령어 정리 2014.02.27 7625
138 webmin 설치하기 2014.02.27 7482
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 12 Next
/ 12

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved