컴퓨터 및 인터넷 팁

티스토리 블로그에 ?category 지우기

신중한 투자가 2021. 2. 24. 07:14
반응형

티스토리 블로그에 있는 글을 클릭하면 url 주소에 아래와 같이 ?category 가 붙는다.

 

 

the-investor.tistory.com/39?category=894584

 

이 ?category를 지우면 아래와 같은 url이 되는데

 

the-investor.tistory.com/39

 

이를 적용하는 방법은 아래와 같다.

 <head> 와 </head> 사이에 다음 코드를 넣으면 된다.

<script type="text/javascript">

if(typeof(history.pushState) == 'function')

{

var CatagoryURL = location.href;

CatagoryURL = CatagoryURL.replace(/\?category=([0-9]+)/ig,'');

history.pushState(null, null, CatagoryURL);

}

</script>

 

 

반응형