A place to find web related blog posts.

How to redirect a Web URL

There are different methods to redirect a Web URL or Page to a different URL or Page. Redirection cab be done using HTML , JavaScript,  Apache or PHP.

In this post we will look at all different ways.

HTML redirect

Using meta refresh tag of HTML.

 <meta http-equiv="refresh" content="0;URL=''" />    

PHP redirect

Using PHP header function. Its sends a 302 redirect. Its must be used at top of page before any HTML tag or PHP code.

 <?php header('Location:'); ?> 

JavaScript redirect

window.location object can be used to redirect to any URL ot page.

 <script> window.location.replace(""); </script>

jQuery redirect

 <script> $(location).attr('href', '') </script>

Apache .htaccess redirect

 Redirect permanent /

There are many ways to redirect in JavaScript and jQuery. There are most commonly used methods.

adminHow to redirect a Web URL
Share this post