구글 검색에서 제외하고 싶거나
혹은 검색에 나오도록 하고 싶은 경우 robots.txt를 사용한다.
네이버를 이용하거나 구글을 이용해서 작성할 수 도 있다.
네이버
searchadvisor.naver.com/guide/seo-basic-robots
robots.txt 설정하기
robots.txt는 검색로봇에게 사이트 및 웹페이지를 수집할 수 있도록 허용하거나 제한하는 국제 권고안입니다. robots.txt 파일은 항상 사이트의 루트 디렉터리에 위치해야 하며 로봇 배제 표준을 따
searchadvisor.naver.com
구글
search.google.com/search-console/welcome
Google Search Console
하나의 계정으로 모든 Google 서비스를 로그인하여 Google Search Console로 이동
accounts.google.com
가이드 문서
developers.google.com/search/docs/advanced/robots/create-robots-txt?hl=ko
사이트를 내소유로 등록하기 애매한 상황에서 내가 구현한 방법
Controller
java profile를 이용해서 환경별로 다르게 적용되도록 했다.
import org.springframework.beans.factory.annotation.Value;
// --------------------------------------------
@Value("${spring.profiles.active}") private String profile;
@ResponseBody
@GetMapping("/robots.txt")
public String robots(HttpServletRequest request) {
logger.info("ROBOTS.TXT 페이지 호출 ");
logger.info("SERVER TYPE ................. [ "+ profile + " ]");
if(!profile.equals("production")) {
return "User-agent: *\n" +
"Disallow: /\n";
}else {
return "User-agent: *\n" +
"Disallow: /svcdrop/request\n";
}
} 'Spring' 카테고리의 다른 글
| [SpringBoot] Session 으로 Login 처리! (0) | 2021.03.26 |
|---|---|
| Spring 특정 URL만 encoding 다르게 처리하기 (0) | 2021.01.21 |
| Springboot bouncycastle 적용하기 (암호화) (0) | 2020.10.12 |
| Springboot Jar systemctl로 실행하기! ( 백그라운드 실행 ) (0) | 2020.10.08 |
| jasypt를 이용한 DB 접속 정보 암호화 방법 (0) | 2020.09.14 |