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 Backlinks?
I am wondering how many people still getting results from 301 redirects from high authority expired domains..? I read few case studies on detailed dot com where the shared some people still making big bucks from this strategy which i think 10beast also implemented few years back.? Is it worth it to test out 301 redirects to money sites.? How many people on the moz community here have implemented this strategy in practical and can share some insights and pros and cons of doing 301 redirects? Many Thanks.
Technical SEO | | asifseo0980 -
Redirect 301 issue. I changed my domain name and Google is killing me.
Hello SEO community: I have this problem, and I don't know exactly what to do. I recently changed my domain from uclasificados.net to uclasificados.com uclasificados.net was a free classified ads for USA in spanish, and was my most affortable site, so I wanted to convert it to .com because I thought it could get more popular with the .com domain. uclasificados.com was before a free classified ads website for Colombia, but was not very popular and had poor traffic so I moved the Colombian content to uclasificados.co. Since I changed my domain from uclasificados.net to uclasificados.com I have lost a lot of ranking, and l my traffic every day is getting lower. I have already checked the 301 redirections and they are working correctly, but even thought I keep getting less traffic and less money. I have also checked with moz tools both sites link juice, and it says that uclasificados.net have better reputation. So I was wondering if I change it back and redirect uclasificados.com to uclasificados.net but I worrie that if I do that, maybe I can make things worse. What do you recommend me?
Technical SEO | | capmartin850 -
260k 301 redirects
Hello, I just found that some of the urls on my site have both ugly characters and some other things I'd like to fix (such as ---- into a single - ) After some local tests i've seen that If i leave some imperfections there will be 48k different urls on the other hand if the renaming procedure is strict i'll have around 260k out of 2.3M urls to be renamed. If I'm going to do this I'll create new canonicals meta tag and redirect old urls with 301 headers to the new location. The content will not change. My big doubt is SEO wise, I know that I'll have better urls, but aren't those too much redirects on a single day? what would you do if you wish to have shipshape urls and know some of these are crap? thanks
Technical SEO | | mylittlepwny0 -
301 redirect from root to /index.aspx
I have taken over the SEO for www.domain.net. The way i've inherited the setup is that www.domain.net is 301 redirected to www.domain.net/index.aspx Looking at top pages and linking root domains in Opensiteexplorer I can see that www.domain.net/index.aspx has 1,006 linking root domains www.domain.net has 806 linking root domains. I assume that www.domain.net is passing the value of it's 806 domain links to www.domain.net/index.aspx via the 301 redirect and because of this would expect www.domain.net/index.aspx to be the strongest page on the site and be the url that ranks in the listings for many relevant searches. It appears however that www.domain.net is what is shown in listings and not www.domain.net/index.aspx ?? Can anyone explain why this might be?? If I do a site: search in Google then www.domain.net is indexed and not www.domain.net/index.aspx ??
Technical SEO | | QubaSEO0 -
301 Redirect & re-use
I have an old site which is being moved to a new tld due to re-branding. I understand I would do a series of 301 redirects from the pages of the old site to capture the authority and move to the new site. However, at some point in the future (probably 1-2 years) we may want to re-use the old site again for a different brand (it has a good brand, just not for what we're going after). Question is - can a redirected site be re-used at some point in the future? And if so, which site would new authority (links, etc.) go to?
Technical SEO | | uwaim20120 -
My home page 301 redirects - is this an SEO problem
When ever a browser calls my site canineconcepts.co.uk, it is automatically 301 redirected to canineconcepts.co.uk/en I am not sure if I should be concerned about this from an SEO perspective or not. Any thoughts?
Technical SEO | | CanineConcepts0 -
Worth Changing Redirect From 302 to 301?
Hi, I'm doing an audit on a site that had a redesign in Dec 2009. For some reason I looked to see what kind of redirects were used from the old pages to the current ones, and it looks like they used 302s, which obviously isn't ideal. Given that it's been so long and those pages have looong since been de-indexed, is it worth me suggesting that they change those old redirects to 301s? My thinking is that if those old pages were linked to externally then I should recommend it, but I can't find any link info on Linkscape/OSE, Majestic SEO or YSE. Any comments appreciated.
Technical SEO | | The_Heavies0 -
What are the SEOmoz-suggested best practices for limiting the number of 301 redirects for a given site?
I've read some vague warnings of potential problems with having a long list of 301 redirects within an htaccess file. If this is a problem, could you provide any guidance on how much is too much? And if there is a problem associated with this, what is that problem exactly?
Technical SEO | | roush0