Redirect to Another Web Page
26 Oct 2020When I was thinking about this post, I thought it would be very short and straightforward. However, it looks like there are at least 3 different ways with pros and significant pitfalls.
In general, there are 3 ways you can make a redirect.
HTML meta
<meta http-equiv="refresh" content="5; url = https://bit.ly/3okeOK4" />
JavaScript
<script type="text/javascript">
window.location.href = "https://bit.ly/3okeOK4"
</script>
Server-side redirects
# Apache
Redirect 301 / http://www.new-website.com
RedirectMatch 301 /blog(.*) http://www.new-website.com$1
Redirect 301 /page.html http://www.old-website/new-page.html
So if you’d like to know their differences and decide which one to use and when then I hope you enjoy this video.
Source code and references:
- HTML redirect example
- JavaScript redirect examples
- 301 & 302 redirect examples
- How to Redirect a Web Page
- http-equiv=”refresh”
Follow me online
Join the Discord: https://discord.gg/V4yMGPQzRB
- GitHub: https://github.com/FSou1
- LinkedIn: https://www.linkedin.com/in/maxim-zhukov-0648a8b5
- Youtube: https://www.youtube.com/channel/UCz6AZvABoICHPpi43y-Hd5g
- Telegram: https://t.me/seasoneddev