본문 바로가기
html

티스토리-도메인주소변경안될때 (URL리디렉션)

by 유봉삼 2023. 5. 3.
728x90
반응형

 


티스토리를 시작하면서 광고가 게시되지 않아 이것블로그관리에서것 알아보다가 

도메인까지 구입하게 되었고

블로그관리에서 구입한 도메인 설정하고 인증까지 받았는데 !!

 

티스토리를 접속하면 주소가 자동변환이 안되서 

이것저것 알아보았는데 다들 각자의 URL리디렉션 코드를 올려줘서 따라해 봤지만 안되는거야!!!

 

그래서 !!!

 

난 메인도메인밖에 없고 서브도메인따위는 없기에 여기저기 알아보다가 !!!

직접 수정을 하였고 테스트했을때 티스토리주소에서 메인도메인주소로 변경이 되는걸 확인할수 있었음 !! 

뭐 이글은 나만 될수도 있고 아닐수도 있지만. 

만약 유용하게 보셨다면 ♡ PLZ^^

 

코드는 아래와 같음 

 

<!--URL리디액션코드 시작!! <head> </head>사이에 붙여넣기 -->
<script type="text/javascript">
var tistoryDomain = 'rrbong515.tistory.com';
var mainDomain = 'rrbong.site';
var online = document.URL; 
var re = /tistory\.com\/manage/ig;
var re2 = /#login-guide/g;                          
var re3 = /rrbong\.site\/##/ig; 
if(online.match(tistoryDomain)) {
    if(online.match(re)){}
    else if(online.match(re2)){}
    else {
    	document.location.href = online.replace(tistoryDomain, mainDomain);}
}
else if(online.match(re3)){
	document.location.href = 'https://rrbong515.tistory.com/manage';}
</script>
<!--URL리디액션코드 끝!! -->

알맞게 바꿔서 삽입>> rrbong515 rrbong.site rrbong  .site

 

var tistoryDomain = 'rrbong515.tistory.com';       << 사용자티스토리주소:도메인 이름을 저장할 변수를 정의


 
var mainDomain = 'rrbong.site';                         << 구매한고메인주소:도메인 이름을 저장할 변수를 정의

 
var online = document.URL;                              << online - 사용자 브라우저의 현재 URL을 저장할 변수를 정의

 
var re = /tistory\.com\/manage/ig;                      << 대/소문자에 관계없이 URL의 어느 위치에든 "tistory.com/manage"                                                                                    문자 열을 포함하는 모든 URL

 
var re2 = /#login-guide/g;                                 <<#login-guide정규식이 적용되는 다른 모든 문자열과 일치시키려고 시도
                                                                              하는 문자열

 
var re3 = /rrbong\.site\/##/ig;                             << 대/소문자에 관계없이 URL의 어느 위치에든 "rrbong.site/##" 문자열을                                                                                 포함하는 모든 URL

 
if(online.match(tistoryDomain)) {                     <<함수를 사용하여 URL tistoryDomain에 가 있는지 확인
   
 if(online.match(re)){}                                   
    else if(online.match(re2)){}                         <<- re("tistory.com/manage")및 re2("#login-guide")정규식이 onlineURL 
                                                                              과 일치하는지 확인. 둘 중 하나라도 일치하면 아무것도 하지 말기.   
                                                                              그렇지 않으면 다음 행으로 진행

    
else {
      document.location.href = online.replace(tistoryDomain, mainDomain);}
}                                                                       <<"document.location.href" 속성을 사용하여 URL을 'rrbong.site'로 설정                                                                               된 "mainDomain" 변수로 리디렉션

 


 
else if(online.match(re3)){                                <<온라인 URL이 re3("rrbong.site/##" )과 일치하면 다음 줄로 진행

 


 
document.location.href = 'https://rrbong515.tistory.com/manage';}
                                                                           <<"rrbong.site/##" 경로가 포함된 URL을
                                                                               "https://rrbong515.tistory.com/manage" URL로 리디렉션
}
 

뭐... 안되면 음 GPT한테 물어보기.... ^-^

 

 

728x90
반응형

'html' 카테고리의 다른 글

사이트 노출시키기-네이버 웹 마스터 도구  (0) 2023.06.11