리뉴얼·이전 · 공식 문서

리다이렉트 설정 방법, 서버 환경별 선택 순서

서버 설정 파일, .htaccess, 서버 스크립트 같은 서버 측 리디렉션을 먼저 쓰고, 그럴 수 없을 때만 meta refresh, 그다음 자바스크립트를 씁니다. Apache·nginx 모두 상태 코드를 적지 않으면 302가 되므로 영구 이동에는 301을 적어 넣습니다.

리디렉션은 같은 301이라도 거는 자리가 여러 곳입니다. 서버 설정 파일, .htaccess, 페이지 코드, HTML 메타 태그, 자바스크립트가 모두 사용자를 새 URL로 보냅니다.

검색엔진이 정확히 읽는 자리는 그중 앞쪽입니다. 우리 서버 환경에서 쓸 수 있는 첫 방법을 고르는 순서와 설정 예를 공식 문서로 정리했습니다.

발견 01

리다이렉트를 거는 방법은 7가지이고, 앞의 3가지가 서버 측입니다

The following table explains the various ways you can use to set up permanent and temporary redirects, ordered by how likely Google is able to interpret correctly (for example, a server side redirect has the highest chance of being interpreted correctly by Google).

아래 표는 영구·임시 리디렉션을 거는 여러 방법을 구글이 정확히 해석할 가능성이 높은 순으로 늘어놓았다. 예를 들어 서버 측 리디렉션이 정확히 해석될 가능성이 가장 높다.

Google Search Central 「Redirects and Google Search」
순서어디서 거나언제설정 예나가는 상태 코드공식 문서 원문
1웹 서버 설정 파일(nginx, Apache 메인 설정)서버 설정을 직접 고칠 수 있을 때location = /old { return 301 https://example.com/new; }301 (적은 코드 그대로)If you have access to your web server configuration files, you may be able to write the redirect rules yourself. Stops processing and returns the specified code to a client.웹 서버 설정 파일에 접근할 수 있다면 리디렉션 규칙을 직접 쓸 수 있다(구글). return 은 처리를 멈추고 지정한 코드를 클라이언트에 돌려준다(nginx).
2Apache .htaccess메인 설정 권한은 없고 폴더 단위 설정만 할 수 있을 때Redirect permanent "/old" "https://example.com/new"301 (permanent 를 적었을 때)If you have access to the main server configuration file, you should put all of your configuration there instead of in .htaccess files. .htaccess files should be used in a case where the content providers need to make configuration changes to the server on a per-directory basis, but do not have root access on the server system.메인 서버 설정 파일에 접근할 수 있다면 모든 설정을 .htaccess 대신 그곳에 둔다. .htaccess 는 root 권한 없이 폴더 단위로 설정을 바꿔야 하는 경우에 쓴다.
3서버 측 스크립트(PHP 등)설정 파일은 못 고치고 페이지 코드는 고칠 수 있을 때header('HTTP/1.1 301 Moved Permanently'); header('Location: https://www.example.com/newurl'); exit();301To set up a permanent redirect with PHP, use the header() function. You must set the headers before sending anything to the screen:PHP 로 영구 리디렉션을 걸려면 header() 함수를 쓴다. 화면에 무엇이든 보내기 전에 헤더를 먼저 보내야 한다.
4제작 도구·호스팅의 리디렉션 기능서버에 직접 접근할 수 없을 때도구 도움말의 리디렉션 메뉴도구가 정한 코드(301인지 확인)If you're using a platform like Blogger or Shopify, the platform may already have built-in redirect solutions.Blogger·Shopify 같은 플랫폼을 쓰면 플랫폼에 리디렉션 기능이 이미 들어 있을 수 있다.
5meta refresh(HTML)서버 측 리디렉션을 쓸 수 없을 때<meta http-equiv="refresh" content="0; url=https://example.com/newlocation">0초면 영구, 0초 초과면 임시로 해석If server-side redirects aren't possible to implement on your platform, meta refresh redirects may be a viable alternative. Place the meta refresh redirect either in the <head> element in the HTML or in the HTTP header with server-side code.플랫폼에서 서버 측 리디렉션을 쓸 수 없다면 meta refresh 가 대안이 될 수 있다. meta refresh 는 HTML 의 head 요소나, 서버 코드로 HTTP 헤더에 넣는다.
6자바스크립트 location서버 측과 meta refresh 모두 쓸 수 없을 때window.location.href = "https://www.example.com/newlocation";렌더링에 성공하면 영구로 해석Only use JavaScript redirects if you can't do server-side or meta refresh redirects. To set up a JavaScript redirect, set the location property to the redirect target URL in a script block in the HTML head.서버 측이나 meta refresh 리디렉션을 쓸 수 없을 때만 자바스크립트 리디렉션을 쓴다. HTML head 의 script 블록에서 location 속성을 리디렉션 대상 URL로 지정한다.
7안내 링크(crypto 리디렉션)어떤 리디렉션도 걸 수 없을 때<a href="https://newsite.example.com/newpage.html">We moved! Find the content on our new site!</a>상태 코드 없음The simplest way to do this is to add a link pointing to the new page accompanied by a short explanation. Don't rely on crypto redirects for letting search engines know that your content has moved unless you have no other choice.가장 쉬운 방법은 새 페이지로 가는 링크와 짧은 설명을 넣는 것이다. 다른 선택이 없는 경우가 아니면 crypto 리디렉션에 기대지 않는다.
example.com 은 예시 도메인입니다. nginx 줄은 nginx 문서의 문법(return code URL;)대로, 나머지 줄은 구글 문서 예시 그대로 옮겼습니다.

구글은 서버 측 리디렉션이 설정 파일이나 서버 스크립트에서 걸린다고 적었습니다(원문: Setting up server-side redirects requires access to the server configuration files (for example, the .htaccess file on Apache) or setting the redirect headers with server-side scripts (for example, PHP).) 앞의 3줄이 여기에 듭니다.

Apache 문서는 메인 설정을 고칠 수 있다면 .htaccess 대신 메인 설정에 두라고 적었습니다. .htaccess 는 호스팅처럼 root 권한이 없는 환경을 위한 자리입니다.

The implementation of server-side redirects depends on your hosting and server environment, or the scripting language of your site's backend.

서버 측 리디렉션을 거는 방법은 호스팅·서버 환경이나 사이트 백엔드의 스크립트 언어에 따라 다르다.

Google Search Central 「Redirects and Google Search」

발견 02

Apache 와 nginx 는 상태 코드를 적지 않으면 302 임시 리디렉션을 보냅니다

서버이렇게 적으면나가는 코드서버 공식 문서 원문
ApacheRedirect "/old" "https://example.com/new"302 (임시)If no status argument is given, the redirect will be "temporary" (HTTP status 302).상태 값을 주지 않으면 리디렉션은 임시(HTTP 302)가 된다.
ApacheRedirect permanent "/old" "https://example.com/new"301 (영구)Returns a permanent redirect status (301) indicating that the resource has moved permanently.자원이 영구히 옮겨졌다는 영구 리디렉션 상태(301)를 돌려준다.
nginxreturn https://example.com/new;302 (임시)In addition, a URL for temporary redirect with the code 302 can be specified as the sole parameter.또한 코드 302의 임시 리디렉션 URL은 매개변수 하나만으로도 지정할 수 있다.
nginxreturn 301 https://example.com/new;301 (영구)Starting from version 0.8.42, it is possible to specify either a redirect URL (for codes 301, 302, 303, 307, and 308) or the response body text (for other codes).0.8.42 버전부터 코드 301, 302, 303, 307, 308에는 리디렉션 URL을, 다른 코드에는 응답 본문 글을 지정할 수 있다.
도메인을 옮기는 영구 이동인데 302가 나가면, 구글은 기존 URL을 검색 결과에 남깁니다.

그래서 설정 줄에 permanent 나 301을 적었는지가 가장 흔한 확인 항목입니다. 건 뒤에는 실제 응답 코드를 직접 봅니다.

Apache 의 Redirect 는 일치한 경로 뒤의 나머지 경로를 대상 URL 뒤에 붙입니다(원문: Additional path information beyond the matched URL-path will be appended to the target URL.) 도메인 전체를 옮길 때 경로마다 짝이 유지되는 이유입니다.

The Redirect directive maps an old URL into a new one by asking the client to refetch the resource at the new location.

Redirect 지시어는 클라이언트에게 새 위치에서 자원을 다시 받으라고 요청해 옛 URL을 새 URL로 잇는다.

Apache HTTP Server 「mod_alias」 Redirect Directive

발견 03

서버 측을 쓸 수 없으면 5번째인 meta refresh 0초를 쓰고, 자바스크립트는 그다음입니다

방법구글 원문네이버 원문
meta refreshGoogle Search interprets instant meta refresh redirects as permanent redirects. Google Search interprets delayed meta refresh redirects as temporary redirects.구글 검색은 즉시 meta refresh 를 영구 리디렉션으로, 지연 meta refresh 를 임시 리디렉션으로 해석한다.만약 해당 주소가 redirect 되는 것을 방문자에게 알리고 싶다면 meta refresh를 사용할 수도 있으며, 네이버의 검색 로봇은 meta refresh를 인식합니다. 다만, HTML 4.01 표준에서는 meta refresh 를 사용하지 않기를 권장하고 있으므로 되도록이면 HTTP redirect를 사용해 주시기 바랍니다.
자바스크립트This means that if you set a JavaScript redirect, Google might never see it if rendering of the content failed.자바스크립트 리디렉션을 걸어도 콘텐츠 렌더링에 실패하면 구글은 그 리디렉션을 끝내 보지 못할 수 있다.따라서 url 링크 또는 redirect 처리 시에는 자바스크립트 함수를 사용하지 않는 것이 검색로봇에게 올바른 정보를 알려주는 데 도움이 됩니다.
네이버는 meta refresh 를 인식하지만 되도록 HTTP 리디렉션을 쓰라고 적었습니다.

meta refresh 는 content 값의 숫자가 0이어야 영구로 읽힙니다. 몇 초 뒤에 넘어가게 하면 구글은 임시로 해석합니다.

자바스크립트 리디렉션은 렌더링이 끝나야 보입니다. 렌더링에 실패하면 구글이 리디렉션을 끝내 보지 못할 수 있어 뒤쪽 순서입니다.

발견 04

같은 순서라도 B2B·B2C·B2G 사이트마다 고르는 첫 줄이 다릅니다

예시 ① 자체 서버를 쓰는 SaaS 기업 사이트(B2B)

개발팀이 nginx 설정을 직접 고칠 수 있는 경우입니다. 1번 줄을 쓰고, 옛 URL과 새 URL 짝마다 return 301 을 적습니다.

짝이 수백 개면 설정 파일 한 곳에 모아 두어야 나중에 찾기 쉽습니다.

예시 ② 웹호스팅에 올린 쇼핑몰(B2C)

호스팅 계정에 root 권한이 없고 .htaccess 만 고칠 수 있는 경우입니다. 2번 줄을 쓰되 permanent 를 빠뜨리면 302가 나간다는 점을 먼저 확인합니다.

제작 도구 안에서 상품 URL을 바꾼다면 4번 줄인 도구의 리디렉션 기능부터 찾습니다.

예시 ③ 공공기관 누리집 게시물 이전(B2G)

서버는 별도 운영 부서가 맡고 수행사는 페이지 코드만 고칠 수 있는 경우입니다. 설정 파일 변경을 운영 부서에 요청하는 것이 1순위이고, 어려우면 3번 줄의 서버 스크립트로 겁니다.

그럼 우리 사이트에는 어떤 순서로 거나요?

  1. 서버 설정 파일, .htaccess, 페이지 코드 중 어디까지 고칠 권한이 있는지 호스팅·운영 담당에게 확인합니다.
  2. 위 표의 1번부터 내려가며 쓸 수 있는 첫 줄을 고릅니다. 앞의 3줄을 쓸 수 없으면 제작 도구 기능이 301을 보내는지 확인합니다.
  3. 영구 이동이면 설정 줄에 301이나 permanent 를 적습니다. 코드를 빼면 302가 나갑니다.
  4. 서버 측을 쓸 수 없을 때만 5번째 줄의 meta refresh 0초를 쓰고, 자바스크립트는 그다음에 씁니다.
  5. 건 뒤 상태 코드와 최종 URL을 확인합니다. 순서는 「리다이렉트 확인 방법」 편에, 301과 302를 고르는 기준은 「301 302 리다이렉트 차이」 편에 자세히 적었습니다.

조사 방법

  • Google Search Central 「Redirects and Google Search」 (문서 수정일 2026-04-14) · 최종 확인일 2026-10-25 · https://developers.google.com/search/docs/crawling-indexing/301-redirects
  • 네이버 서치어드바이저 「웹 페이지의 이동」 · 최종 확인일 2026-10-25 · https://searchadvisor.naver.com/guide/seo-basic-redirect
  • Apache HTTP Server Version 2.4 Documentation 「mod_alias」 · 최종 확인일 2026-10-25 · https://httpd.apache.org/docs/2.4/mod/mod_alias.html
  • Apache HTTP Server Version 2.4 Documentation 「Apache HTTP Server Tutorial: .htaccess files」 · 최종 확인일 2026-10-25 · https://httpd.apache.org/docs/2.4/howto/htaccess.html
  • nginx documentation 「Module ngx_http_rewrite_module」 · 최종 확인일 2026-10-25 · https://nginx.org/en/docs/http/ngx_http_rewrite_module.html
  • 거는 방법 7가지와 순서는 구글 「Redirect types」 표의 해석 정확도 순서에 서버 환경별 자리를 더해 묶은 것입니다. 묶는 방식은 편집 판단입니다.
  • 설정 예의 nginx 줄은 구글 문서 예시를 nginx 문서의 return 문법에 맞춰 적었습니다. 나머지 설정 예는 구글 문서 예시 그대로입니다.
  • 예시 ①②③은 이해를 돕기 위해 만든 가상 상황이며, 실제 기업·기관의 사례가 아닙니다.
  • 원문은 영어판(hl=en)이고, 도구·보고서 이름은 같은 문서 한국어판(hl=ko) 표기를 따랐습니다. 네이버 가이드와 Apache·nginx 문서는 페이지에 수정일이 없습니다.