Want to redirect URL? Want to redirect one page to another page? We will give all programming language’s solutions. We will make it simple.
Code for Redirect Page URL using HTML
Use following HTML code to redirect the page URL,
<meta http-equiv="refresh" content="0; url=http://www.steptoinstall.com/"/>
here 0 is seconds of waiting, and url= having your destination URL.
One more way available in HTML,
<link rel="canonical" href="http://www.steptoinstall.com"/>
Code for Redirect Page URL using JavaScript
Below JavaScript code use to redirect page URL,
<script>
window.location.href = "http://www.steptoinstall.com"
</script>
place above code in header. You can this same code for JavaScript events.
If you want to do HTTP redirect,
<script>
window.location.replace("http://www.steptoinstall.com");
</script>
Code for Redirect Page URL using JQuery
You can use JavaScript code here or use following jquery code,
$(location).attr('href',"http://www.steptoinstall.com");
or
$jq(window).attr("location","http://www.steptoinstall.com");
Code for Redirect Page URL using PHP
Use below any one method for page URL redirect,
<?php
or
header( "refresh:5;url=www.steptoinstall.com" );
header("Location: http://www.steptoinstall.com");
?>
Code for Redirect Page URL using Java
Use following Java Servlet code to redirect,
HttpServletReponse.sendRedirect("www.steptoinstall.com");
Code for Redirect Page URL using ASP .Net
Use below ASP .Net code to redirect page URL,
<%
Response.Redirect "http://www.steptoinstall.com"
%>
Code for Redirect Page URL using PERL
In PERL language, using CGI we can redirect page URL by,
my $url = "http://www.steptoinstall.com";
my $ka = CGI->new;
print $ka->redirect($url);
else use following code too,
print redirect(-url=>'http://www.steptoinstall.com');
Code for Redirect Page URL using Python
Try any one from following 3 methods in python page URL redirect,
from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
(r'^one/$', redirect_to, {'url': '/another/'}),)
or
from django.views.generic import RedirectView
urlpatterns = patterns('',
(r'^one/$', RedirectView.as_view(url='/another/')),)
or using urllib2,
import urllib2
def get_redirected_url(url):
opener = urllib2.build_opener(urllib2.HTTPRedirectHandler)
request = opener.open(url)
return request.url
print get_redirected_url("http://www.steptoinstall.com/")
Code for Redirect Page URL using AngularJS
Somewhere you may get following codes,
$location.absUrl() == 'http://www.steptoinstall.com'
$location.path('http://www.steptoinstall.com')
$location.url('http://www.steptoinstall.com')
It may work. But most of time it won’t work. Just use JavaScript or JQuery methods.
Code for Redirect Page URL using NodeJS
Following code should be use for redirect page URL,
http.get('*',function(req,res){
res.redirect('https://www.steptoinstall.com'+req.url)
})
Code for Redirect Page URL using Ruby on Rails
For Ruby on Rails use below Rails code to redirect
get "/blog" => redirect("http://www.steptoinstall.com")
Using .htaccess file is different one. We’ll solve this problem with another article.
How to Redirect Page URL using HTML JavaScript Jquery PHP
Latest posts by KarSho (see all)
- Step to uninstall Android Studio fully on Mac - June 14, 2018
- Step to install new Python Package from inside of IPython - June 14, 2018