.htaccess code
-
I've got a .htaccess file set up on a site to redirect specific old pages to specific new pages on a different site:
eg
Redirect 301 /oldpage.html https://www.newsite.co.uk/newpage.html
Redirect 301 /oldpage2.html https://www.newsite.co.uk/folder/
I have two questions:
1. Is that all the file needs? Or does it need any "rewrite engine on" type code?
2. I would also like to include code to "mop up" any other URLs and redirect them to the root, so that
/anyotherpage.html redirects to newsite.co.uk
Is there a way to do this?
-
What I'm looking to do is pass the link juice on from about 5,000 backlinks still pointing at our old site (which exists in domain form only a present) to the new site. Are these links pointed to the home page? Or are these pointed at relevant landing pages? If to the home page (and page is same on new site) nothing is needed. If these links are pointed to a landing page, you will need to route them to a related page on the new site and 301.
Are you saying there's not point in using a 301 if the page doesn't exist? Yes, no point unless there is a new landing page that is some-how related.
I don't really understand why you'd use a 301 if the page still existed...? If the page is on the new site and is the same url, no 301 is needed.
-
Thanks Kevin - I'm not sure I completely understand though.
What I'm looking to do is pass the link juice on from about 5,000 backlinks still pointing at our old site (which exists in domain form only a present) to the new site.
Are you saying there's not point in using a 301 if the page doesn't exist? I don't really understand why you'd use a 301 if the page still existed...?
-
Not really, since the resource doesn't exist anymore. If the resource exists (or something close to it) it would be a 301 and link juice will be passed (although not 100% of it).
If you have a relevant page, you should always 301 them. I would go through analytics and makes sure any "valuable" page has a relevant landing page. If no relevant landing page exists, you should 404 the result will eventually fall off.
I would also advise on creating a custom 404 page that explains what they are looking for and doesn't exist and show alternative pages/search bar. Users may get confused if they were looking for something specific and land at your home page.
-
Hi Kevin
Many thanks for this. Is a 404 as effective in passing on link juice as a 301?
-
2.) Are you talking about a catch-all? You can use 404 and redirect them to whatever. Try to redirect as much as possible though. Good luck!
ErrorDocument 404 /index.html
-
Thanks Andy, much appreciated. I'll look forward to the code
-
Your current redirects are fine and the best way is if its live to test it. Even thought I knew I had done it right recently when i went to https, I still do several random checks. They all came back as working - but no harm in testing.
Your point 2 is doable and as I am not on my laptop I don't have the code to hand. I will update in a few hours when back in the office for you, but your point 1 is correct.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
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
-
Can bad html code hurt your website from ranking ?
Hello,For example if I search for “ Bike Tours in France” I am looking for a page with a list of tours in France.Does it mean that if my html doesn’t have list * in the code but only that apparently doesn’t have any semantic meaning for a search engine my page won’t rank because of that ?Example on this page : https://bit.ly/2C6hGUn According to W3schools: "A semantic element clearly describes its meaning to both the browser and the developer. Examples of non-semantic elements: <div> and - Tells nothing about its content. Examples of semanticelements: <form>, , and- Clearly defines its content."Has anyone any experience with something similar ?Thank you, </form>
Technical SEO | | seoanalytics0 -
Is my knowledge graph code wrong?
I inserted the Knowledge Graph code on our site last week and am still not seeing the knowledge graph in our search results. Is something incorrect with my code? <script type="<a class="attribute-value">application/ld+json</a>"> { "@context" : "http://schema.org", "@type" : "Organization", "name" : "IssueTrak", "url" : "http://www.issuetrak.com/", "sameAs" : [ "http://www.facebook.com/issuetrak", "http://www.twitter.com/issuetrak", "http://plus.google.com/google.com/+Issuetrak"] } script>head> I suspect it is the alignment of the "{" and "}" but others in the company say that doesn't matter. Any other explanations for why the KG isn't showing in the results? Thanks I did test it with Google's Structured Data Testing Tool and got the "all's good."
Technical SEO | | Nobody15969167212220 -
Exclude status codes in Screaming Frog
I have a very large ecommerce site I'm trying to spider using screaming frog. Problem is I keep hanging even though I have turned off the high memory safeguard under configuration. The site has approximately 190,000 pages according to the results of a Google site: command. The site architecture is almost completely flat. Limiting the search by depth is a possiblity, but it will take quite a bit of manual labor as there are literally hundreds of directories one level below the root. There are many, many duplicate pages. I've been able to exclude some of them from being crawled using the exclude configuration parameters. There are thousands of redirects. I haven't been able to exclude those from the spider b/c they don't have a distinguishing character string in their URLs. Does anyone know how to exclude files using status codes? I know that would help. If it helps, the site is kodylighting.com. Thanks in advance for any guidance you can provide.
Technical SEO | | DonnaDuncan0 -
Google Schema Code for Organisation
I've created the Google Schema code for an organisation. Should this go in the template HTML so it would be shown on all pages or just on the home page?
Technical SEO | | CharlBritton0 -
Combining 2 blogs into one. What is quicker, easier and better - rel canonical or an htaccess/ 301?
The objective I have is to archive an entire blog (which I no longer have time to keep up) with multiple posts over 4years , into another blog as a a folder. My question: would it be quicker and easier to do a rel canonical, or separately list all pages in htaccess and do a 301 redirect.
Technical SEO | | charlesgrimm0 -
500 error codes caused by W3 Total Cache plugin?
Hello Everyone, I operate a site (http://www.nationalbankruptcyforum.com) that has been receiving 500 error codes in Webmaster Tools as of late. This morning, webmaster tools showed 129 500 crawling errors. I've included one of the URLs that contained an error message here: http://www.nationalbankruptcyforum.com/marriage-and-bankruptcy/do-my-wife-and-i-both-have-to-file-for-bankruptcy/ I've been getting these errors now for about 3 weeks and they've mostly been on obscure, strange URLs (lots of numbers etc.) however, this morning they started showing up on pages that will actually be trafficked by users. I'm really not sure where they're coming from, although I do believe it's a software issue as I've had my hosting company take a look to no avail. I have had some development work done recently and am running the W3 Total Cache plugin (my site is built on WP). I also run the Yoast SEO plugin and rely on it to publish an XML sitemap among other things. Anyone have any idea where these 500 errors originate from? Thanks, John
Technical SEO | | oconn1460 -
Non-www to www code not working in htaccess
I use the same rewrite code on every site to consolidate the non-www and www versions. All sites in Joomla, linux hosting. Code is as follows: RewriteEngine On rewritecond %{http_host} ^site.com/ rewriteRule ^(.*) http://www.site.com/$1 [R=301,L] Immediately following this code, I also rewrite /index.php to /. Thing is, I can get index.php to rewrite correctly but the non-www won't rewrite to www. I use the same code on every site but for some reason it's not working here. Are there common issues that interfere with rewriting a non-www to www in htaccess that could be interfering with the code I'm using above?
Technical SEO | | Caleone0 -
Putting nav code at the bottom of a page?
Hey, We are doing a re-design on our websites and we have run into a little problem. Basically we need to put the nav code at the bottom of the page (so when you view source all the nav code it at the bottom) but the nav will of course still show at the top. Will this cause any issues with our SEO? Will it make the nav seem less important or get crawled less? Thanks for the help in advance! Ricky
Technical SEO | | Fubra0