So, suppose you want to redirect your site hosted on Netlify
example.com/blog and you don’t want to pay for the hosting server or use any other third party application.
Then our beloved Netlify provides an awesome feature of creating redirects easily.
All you need to do is, create a
_redirect file in the public folder.
Now, we need to edit the file in following format,
# The Comments Can be done by using # at the beginning.# We will suppose our main domain is example.com.np# and we have to redirect example.com.np/blog to example.com/blog# Example(s):/blog https://example.com/blog 200!
The first part ( /blog ) comes after the main domain ( example.com.np ) and we ought to redirect it to ( https://example.com/blog ) as mentioned in second part.
The third part has two sections,
! , first part is the status code we want to use in that redirect (
301 by default ), and second part ( ! ) if used, will let us to override any existing content in the path or not; which is
Now I like using this feature to redirect visitors to my social links as,
/fb https://fb.com/ashokcpg 200!
/twitter https://twitter.com/ashokcpg 200!
/insta https://instagram.com/ashokcpg 200!
So, whenever someone visits/clicks on link https://ashokcpg.com.np/fb, they shall be redirect to the URL mentioned above.
You can find more about redirects in Netlify by Clicking Here,
I hope you liked it.