301 redirect using javascript
-
Can I use javascript code to redirect(301) a webpage?
-
I did this on my wordpress site. Here are my instructions:
https://mza.bundledseo.com/community/q/switched-from-wix-to-wordpress-dreaded-hashtag-url
-
Hi GenSEO..
301 is a server response code and handled by the server on linux / unix systems usually via htaccess if you have access to the server then you would use this method, unless its a IIS server (Windows) in which case its a little different.
You can test your server package if you don't know what server you're on..
PHP for Linux / Unix / Apache put this at the very top of the page
ASP for Windows Servers
`<%@ Language=VBScript %> <% ' Permanent redirection Response.Status = "301 Moved Permanently" Response.AddHeader "Location", "http://``www.mysite.com/new-page.html``/" Response.End %>`
That said, the best option if you do not have access to the server is to use a META refresh, some search engines will treat this as 30x redirect, by placing this at the top of the page
HTML Page Redirect -
Are they literally just flat HTML files - not served from a CMS or anything?
Do you know what kind of server you are on? You can probably find out here http://news.netcraft.com/ (box top left)
If you're on Apache, then see if you can edit your .htaccess file - this should be in the root of your web space. Note: editing .htaccess can seriously muck up your site if you get it wrong. It depends what kind of redirect you want to do, but if you're just looking to redirect abc.html to xyz.html then you'd add in a line like this:
redirect 301 /abc.html /xyz.html
If you're on IIS I'd have to bow to someone with better knowledge of IIS...
-
I have a html site,I cant use server side scripting languages.So in your opinion how to redirect html site?
-
No, Javascript is run at the client (browser) side and a 301 has to be done server side.
However, it's really quite simple to do using PHP or ASP - have a look at http://www.webconfs.com/how-to-redirect-a-webpage.php which gives sample code for various languages.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
301 Redirects Showing As 307 Redirects
Hi, Our clients are adamant that they have set up 301 permanent redirects on their websites, but when we check using Screaming Frog and various online HTTP status code checkers they are showing as 307 temporary redirects. Examples;
Technical SEO | | Webpresence
http://www.lifestylelifts.co.uk/home-lifts/
http://www.terrylifts.co.uk/ Again, the client says they are seeing 301 redirects. Why are we seeing 307's? Who is right? Very puzzling, any theories would be very much appreciated 🙂 Thanks in advance. Lee.0 -
301 redirect file question
Hi Everyone, I am creating a list of 301 redirects to give to a developer to put into Magento. I used Screaming Frog to crawl the site, but I have noticed that all of their urls 302 to another page. I am wondering if I should 301 the first URL to the url on the new site, or the second. I am thinking the first, but would love some confirmation. Thank you!
Technical SEO | | mrbobland0 -
301 Redirect Expert
I have hired two website people from odesk and had bad experience in 301 redirects. One never got it done and the other cause my website to crash on a 500 error code, he load all the redirects in a script on .htaccess on my wordpress site on godaddy, there were 1400 redirect.Can somebody recommend a expert for my redirect problem.
Technical SEO | | tjacquet0 -
Max Number of 301 Redirections?
Hi, We currently made a re-design of a website and we changed all our urls to make them shorter. I made more than 300 permanent redirections but plenty more are needed since WMT is showing some more 404s from old urls that I hadn't seen because they were dynamic. The question is, please, is there a limit? I think we have more than 600 already. We don't want to create a php commando to redirect all the old ones to our home, we are redirecting them to their correspondent url. By the way, Im doing them with the 301 method in .htaccess. Thanks in advance.
Technical SEO | | Tintanus0 -
Canonicals & 301 Redirects to new Domain
We will be changing our domain name soon and I want to make sure I'm not painting myself into a corner. Of course, I want to transfer as much link equity as possible. Question #1: Do I need to define a canonical from the old domain to the new domain? Question #2: Do I also need to put 301s in place on the pages with link equity, or is there a way to apply 301s across the entire site on all pages? Any input would be appreciated greatly! Thanks!
Technical SEO | | BVREID0 -
Delete 301 redirected pages from server after redirect is in place?
Should I remove the redirected old pages from my site after the redirects are in place? Google is hating the redirects and we have tanked. I did over 50 redirects this week, consolidating content and making one great page our of 3-10 pages with very little content per page. But the old pages are still visible to google's bot. Also, I have not put a rel canonical to itself on the new pages. Is that necessary? Thanks! Jean
Technical SEO | | JeanYates0 -
IIS Server Load for 500 Page Level 301 Redirects
We are migrating content from 10 sub domains to our www site. On an IIS sever, what is potential server load impact, if any, for setting up 500 plus page level redirects?
Technical SEO | | DigitalMkt0 -
Javascript
Hi mozzers, For my website I use various affiliate programs on commission junction. Some of the text ads are in javascript. Will google read the text ads or not? Cheers, Peter
Technical SEO | | PeterM220