RadarURL

웹서버,WAS
2026.04.01 03:15

일반적인 Htaccess 301 리디렉션 규칙

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

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

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

 

단일 페이지를 어떻게 리디렉션합니까?

Redirect 301 /pagename.php http://www.domain.com/pagename.html

 

전체 사이트 또는 도메인을 새 사이트로 리디렉션하는 방법은 무엇입니까?

Redirect 301 / http://www.domain.com/

 

전체 사이트를 하위 폴더로 어떻게 리디렉션합니까?

Redirect 301 / http://www.domain.com/subfolder/

 

하위 폴더를 다른 웹 사이트로 어떻게 리디렉션합니까?

Redirect 301 /subfolder http://www.domain.com/

 

파일 확장자를 리디렉션하지만 페이지 이름은 어떻게 유지합니까?

예 : .html 확장자가 동일한 파일 이름을 사용하지만 .php 확장자를 사용하려는 경우.

RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php

 

Rewrite를 사용하여 기존 도메인에서 새 도메인으로 리디렉션하는 방법은 무엇입니까?

RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

 

Rewrite를 사용하여 www가 아닌 도메인에서 www 하위 도메인으로 리디렉션하는 방법은 무엇입니까?

RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

 

Rewrite를 사용하여 하위 디렉토리가있는 도메인을 www 위치로 리디렉션하는 방법은 무엇입니까?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/directory/index.html [R=301,NC]

 

Rewrite를 사용하여 이전 도메인에서 전체 경로 및 쿼리 문자열이 포함 된 새 도메인으로 리디렉션하는 방법은 무엇입니까?

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC]

 

Rewrite를 사용하여 하위 디렉토리가있는 기존 도메인에서 하위 디렉토리가없는 새 도메인으로 리디렉션하지만 전체 경로와 쿼리 문자열은 어떻게 포함합니까?

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$
RewriteRule ^(.*) http://www.katcode.com/%1 [R=302,NC]

 

루트 디렉토리에 파일이있는 쿼리 매개 변수를 사용하여 URL을 다시 쓰고 리디렉션하는 방법은 무엇입니까?

예 : 원래 URL은 http://www.website.com/index.php?id=3이고 새 URL은 http://www.website.com/path-to-new-location/

RewriteEngine on
RewriteCond %{QUERY_STRING} id=3
RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301]

 

쿼리 매개 변수로 URL을 리디렉션하고 하위 디렉토리에 파일을 배치하는 방법은 무엇입니까?

예 : 원래 URL은 http://www.website.com/sub-dir/index.php?id=3이고 새 페이지는 http://www.website.com/path-to-new-location/

RewriteEngine on
RewriteCond %{QUERY_STRING} id=3
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]

 

중복 콘텐츠를 제거하기 위해 HTTP에서 사이트를 HTTPS로 어떻게 리디렉션합니까?

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

중복 콘텐츠를 제거하기 위해 HTTP에서 HTTPS로 사이트를 어떻게 리디렉션합니까?

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

 

index.html 또는 index.php를 어떻게 제거하고 루트로 리디렉션합니까?

RewriteEngine On
RewriteCond %{THE_REQUEST} /index.php HTTP [NC]
RewriteRule (.*)index.php$ /$1 [R=301,L]
RewriteEngine On
RewriteCond %{THE_REQUEST} /index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]

 

URL 루트 수준에서 쿼리 문자열을 유지하면서 쿼리 매개 변수가있는 URL을 디렉토리 기반 구조로 다시 쓰고 리디렉션하는 방법은 무엇입니까?

예 : 원래 URL은 http://www.website.com/index.php?id=100이고 새 페이지는 http://www.website.com/100/입니다.

RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]

 

URL 서브 디렉토리에 쿼리 문자열 매개 변수를 유지하면서 쿼리 매개 변수를 사용하여 URL을 디렉토리 기반 구조에 다시 쓰는 방법은 무엇입니까?

예 : 원래 URL은 http://www.website.com/index.php?category=fish이며 새 페이지는 http://www.website.com/category/fish/입니다.

 

RewriteEngine On
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA]

 

기존 웹 사이트를 새 도메인으로 리디렉션하고 URL 경로를 유지하는 방법은 무엇입니까?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC]
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L]

새 도메인으로 경로를 전달하지 않으려면 마지막 행을 다음으로 변경하십시오.
RewriteRule ^(.*)$ http://www.example-new.com/ [R=301,L]

 

URL없이 슬래시를 다시 작성하고 추가하는 방법은 무엇입니까?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/$1/ [R=301,L]

 

블로그 하위 도메인에서 블로그 폴더로 어떻게 리디렉션합니까?

예 : blog.oldsite.com을 www.newsite.com/blog/로 리디렉션

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI}/ blog
RewriteRule ^(.*) http://www.somewhere.com/%{REQUEST_URI} [R=302,NC]
RewriteRule ^(.*) http://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC]

 

한 디렉토리를 다른 디렉토리로 어떻게 리디렉션합니까?

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)/old-directory/(.*)$ $1/new-directory/$2 [R,L]

출처 : https://cnisoft.tistory.com/174

?

공부 게시판

공부에 도움되는 글을 올려주세요.

  1. [공지] 공부 게시판 입니다.

    Date2003.08.18 By처누 Views947528
    read more
  2. 일반적인 Htaccess 301 리디렉션 규칙

    Date2026.04.01 Category웹서버,WAS ByJaeSoo Views5
    Read More
  3. [Windows] OWASP ZAP 사용법

    Date2025.09.29 Category웹서버,WAS ByJaeSoo Views796
    Read More
  4. [웹 취약점] 웹서버 디렉토리 리스팅 방지

    Date2025.09.29 Category웹서버,WAS ByJaeSoo Views701
    Read More
  5. [apache] HTTP/HTTPS 리다이렉트(Redirect/Rewrite) 하는 방법

    Date2025.09.11 Category웹서버,WAS ByJaeSoo Views755
    Read More
  6. http를 https로 리다이렉트하는 여러가지 방법

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views692
    Read More
  7. SSL인증서 없이 HTTPS에서 HTTP로 되돌리기

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views916
    Read More
  8. [SSL] win-acme, Let's encrypt로 무료 SSL 인증서 발급

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views1074
    Read More
  9. [SSL] Windows 10에서 Let's Encrypt로 SSL 인증서 무료 발급받기

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views772
    Read More
  10. 무료로 https SSL/TLS 인증서를 발급받을 수 있는 인증 기관

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views826
    Read More
  11. 아파치 서버에 https SSL 인증서 적용하는 방법 (apache httpd)

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views608
    Read More
  12. 아파치2(Apache2) SSL HTTPS 적용하기

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views931
    Read More
  13. 아파치 웹서버에 멀티 도메인에 대한 80, 443 포트 설정하는 방법

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views835
    Read More
  14. 용량 산정 (동시 접속자 계산)

    Date2016.05.05 Category웹서버,WAS ByJaeSoo Views1627
    Read More
  15. 아파치 httpd.conf 재시작 없이 설정 적용하기

    Date2016.05.02 Category웹서버,WAS ByJaeSoo Views1434
    Read More
  16. Tomcat JVM heap memory set 및 size

    Date2016.03.23 Category웹서버,WAS ByJaeSoo Views1316
    Read More
  17. Java 실행 옵션 정리

    Date2016.03.23 Category웹서버,WAS ByJaeSoo Views1375
    Read More
  18. [JAVA] 개발환경설정 - 표준프레임워크

    Date2016.01.02 Category웹서버,WAS ByJaeSoo Views1636
    Read More
  19. Tomcat 7.x 와 8.x 간의 default configuration 차이

    Date2016.01.02 Category웹서버,WAS ByJaeSoo Views1429
    Read More
  20. 톰캣 8 소개

    Date2016.01.01 Category웹서버,WAS ByJaeSoo Views1116
    Read More
  21. 리눅스 webalizer를 통한 apache log(웹서버 접속 통계) 분석하기 (추천)

    Date2014.12.25 Category웹서버,WAS ByJaeSoo Views1987
    Read More
Board Pagination Prev 1 2 3 Next
/ 3


즐겨찾기 (가족)

JAESOO's HOMEPAGE


YOUNGAE's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

숭실대 컴퓨터 통신연구실 (서창진)

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

아스가르드 좋은사람/나쁜사람

JServer.kr

제이서버 메타블로그

재수 티스토리


즐겨찾기 (강의, 커뮤니티)

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너