.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
-
Appending a code at the end of a URL
Hi All, Some real estate/ news companies have a code appended to the end of a URL https://www.realestate.com.au/property-house-qld-ormiston-141747584 https://www.brisbanetimes.com.au/national/queensland/childcare-centre-could-face-prosecution-for-leaving-child-on-hot-bus-20230320-p5ctqs.html Can I ask if there's any negative SEO implications for doing this? Cheers Dave
Technical SEO | | Redooo0 -
Repeating Content Within Code On Many Pages
Hi, This is sort of a duplicate content issue, but not quite. I'm concerned with the way our code is written and whether or not it can cause problems in the future. On many of our pages (thousands), our users will have the option to post comments. We have a link which opens a JavaScript pop-up with our comments guidelines. It's a 480 word document of original text, but it's preloaded in the source code of every page it appears on. The content on these pages will be relatively thin immediately, and many will have thin content throughout. I'm afraid so many of our pages look the same in both code and on-site content that we'll have issues down the line. Admittedly, I've never dealt with this issue before, so I'm curious. Is having a 480 word piece of text in the source code on so many pages an issue, or will Google consider it part of the template, similar to footer/sidebar/headers? If it's an issue, we can easily make it an actual pop-up hosted on a SINGLE page, but I'm curious if it's a problem. Thanks!
Technical SEO | | kirmeliux0 -
.htaccess: Multiple URLs catches filename
Hi, I have the following line in my .htaccess:
Technical SEO | | rasmusbang
RewriteRule privacy stdpage.php?slug=privacy [L] So if you go to the www.mysite.com/privacy it takes the stdpage.php with the argument above. But if you go to www.mysite.com/privacysssssssss catches the same file. How can I prevent this? It will give me multiple URLs with the exact same content. I have a 404 page which i would like to show instead when the match is not 100%. -Rasmus0 -
Htaccess query
I'm currently working on a live version of a clients website which has duplication issues. With .htaccess, I need to rewrite URL's of the following format: vacancy.php?id=802 to vacancy/?id=802 I tried adding the following line but it returned a 500, and don't want to keep taking the site out. RewriteRule ^vacancy/?id=([0-9]+)$ vacancy.php?id=$1 [R=301, L]
Technical SEO | | AndrewAkesson0 -
Htaccess rewrites
We’re using wordpress, and we have the following in the .htaccess: BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] END WordPress We have a URL like http://subdomain.example.com/select-a-card/?q=fuel, and I want to rewrite it so that it becomes http://subdomain.example.com/fuel-card/ What do I need to add to the htaccess to do this?? Thanks,
Technical SEO | | AndrewAkesson0 -
Suggestions on good framework/code for building an optimized website?
There seem to be quite a few template, framework, and theme options for building a site optimized for search. I'm currently looking at Socrates and Genesis premium themes for Wordpress. Does anyone have experience or suggestions on these resources?
Technical SEO | | ksracer0 -
URL with tracking code
Hi there, At the company i am currently working for we have a problem with shortcut url with tracking in it. They send a lot of brochures with a shortcut URL which redirects to the page of the event with tagging. For example The real URL is:
Technical SEO | | RuudHeijnen
http://www.sbo.nl/cursussen/schoolleider-primair-onderwijs/ The URL in the brochure is:
www.sbo.nl/schoolleiderpo this then redirects to: h
ttp://www.sbo.nl/cursussen/schoolleider-primair-onderwijs/?utm_source=direct&utm_medium=shortcut&utm_campaign=schoolleiderpo Now we can measure the effect of the brochure on on-line traffic and conversion. This is great but a lot of website link to that shortcut url and if the event is put offline the links to it generate an 404. We have now about 800 backlinks that generate this 404 and i want to fix it. Another big problem "i think" is the possibility that google will index this url with tagging. Now i have 2 options: 1. look at al the url with that 404 and redirect them with a 301 to the best page 2. create the shortcut on an page that is most suitable but then i will get the tagging in the URL and i guess google will see this as dublicate content. It is possible that in the future the shortcut url will be used again. What would you suggest as the best sollution.0 -
I need some HTACCESS help (Magento)
Hi Guys, I need some help on this htaccess issue in Magneto. So here is what I am trying to do: I wanted to change mysite.com/index.php/etc to mysite.com/etc so I turned on the web friend URLS. That did that, BUT there are still two versions of every page on the site. www.mysite.com/etc and mysite.com/index.php/etc So that isn't good for SEO. So then I applied a 301 matching redirect, RedirectMatch 301 /index.php/(.*) http://www.mysite.com/$1 That solved that problem. But now I am not able to log into the admin. It is mysite.com/index.php/pg45admin. It should redirect to mysite.com/pg45admin but the page just hangs.... It goes into a continuous loop. I tired using the custom URL and then the site crashed and I had to redo it. So what do I need to do for this to work?
Technical SEO | | netviper0