301 redirect help
-
Hey guys, I normally work in WordPress and just use a 301 redirect plugin. I bought a site and rather than maintain two similar ones have decided to redirect one to the other.
I am having trouble with the .htaccess file. Here is an example. These are two redirects:
redirect 301 /category/models/next/2
redirect 301 /category/modelsI want both of these URLs to redirect to the same URL of the new site. However, the /category/models is the only one working. It redirects to the new page just fine. The /category/models/next/2 is redirecting to nearly the same URL on the new site, only it is adding /next/2 to the end and that is bringing up a 404.
Why is it adding /next/2 to the new URL? How can I fix this? There are several doing this. Help appreciated!
-
Hi,
I just did this and had similar issues
It looks like the .htaccess is correct at the old domain.
but you need to put in re-directors at the new domain that will take in these extra items due to these directories do not exist at the new domain.
There could be an easier way, without putting a redirect after a redirect (which possibly losses a little extra juice) but I am not aware of a way without redirecting all 404 queries.
after you have put back the 301 that was working at the OLD domain In the .htaccess at the NEW domain you would put
Redirect /category/models/next/2 http://www.example.com/
This will tell any queries for http://www.example.com/category/models/next/2
to redirect to http://www.example.com or whatever you put in....
hope this helps!
-
Didn't seem to fix it. None of the redirects worked anymore. They all just changed the domain name, not redirect to the specified URL.
-
Try changing the last line to:
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]
-
This is at the top of the .htaccess file:
rewritecond %{HTTP_HOST} ^www.old-domain.com$ [OR]
rewritecond %{HTTP_HOST} ^old-domain.com$
rewriterule ^$ "http://new-domain.com/" [R=301,L]Does this need to be changed?
-
Whats in your .htaccess file at the moment?
I think in your .htaccess your redirect should be setup something along the lines of:
RewriteCond %{HTTP_HOST} ^www.old-domain.com$ [NC]
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]
Someone else could probably make that a bit neater but something like this should work.
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
-
Is it worth keeping a decades-old domain that's merely 301 redirecting to the main domain?
Hi fellow Moz SEOs, We have a bigger client who we just did an SEO Site Audit for, and it was discovered that they have several domain names that are simply 301 redirecting to their main domain name. One of their domains in particular is decades old, and the client is asking if there is any value in keeping it (and the others), or simply leaving them as-is. Considering the domain age, does anyone have any recommendations? Much appreciated, Zack Barton
Intermediate & Advanced SEO | | Zack
Barton Interactive
(833) 442.6853 // office
(408) 910.7750 // mobile
https://bartoninteractive.com0 -
PushState for redirects
Is it possible to use PushState for redirects from one site to another?
Intermediate & Advanced SEO | | rgamedia_seo0 -
What happens to 301 redirect if the site taken down?
I understand 301 redirect carries over the page value to the page its being redirected to. However what happens if for example, I do a 301 redirect from example.com to example.co.uk, 2 months later I take down hosting and cancel domain for example.com, would I lose the page value that was being carried over to example.co.uk? Do I need to keep both domains active?
Intermediate & Advanced SEO | | Marvellous0 -
For URLs that require login, should our redirect be 301 or 302?
We have a login required section of our website that is being crawled and reporting as potential issues in Webmaster Tools. I'm not sure what the best solution to this is - is it to make URLs requiring a login noindex/nocrawl? Right now, we have them 302 redirecting to the login page, since it's a temporary redirect, it seems like it isn't the right solution. Is a 301 better?
Intermediate & Advanced SEO | | alecfwilson0 -
How to redirect an url in .htaccess when "redirect 301" doesnt work
I have an odd page url, generated by a link from an external website, it has: %5Cu0026size=27.4KB%5Cu0026p=dell%20printers%20uk%5Cu0026oid=333302b6be58eaa914fbc7de45b23926%5Cu0026ni=21%5Cu0026no=24%5Cu0026tab=organic%5Cu0026sigi=11p3eqh65%5Cu0026tt=Dell%205210n%20A4%20Mono%20Laser%20Printer%20from%20Printer%20Experts%5Cu0026u=fb ,after a .jpg image url, and I can't get it redirect using the redirect 301 in .htaccess to the properly image url as I use to do with the rest of not found urls eg: /15985.jpg%5Cu0026size=27.4KB%5Cu0026p=dell%20printers%20uk%5Cu0026oid=333302b6be58eaa914fbc7de45b23926%5Cu0026ni=21%5Cu0026no=24%5Cu0026tab=organic%5Cu0026sigi=11p3eqh65%5Cu0026tt=Dell%205210n%20A4%20Mono%20Laser%20Printer%20from%20Printer%20Experts%5Cu0026u=fb to just: /15985.jpg
Intermediate & Advanced SEO | | Status0 -
301 Redirecting Multiple Domains
I have several complete websites with blogs setup for different geo locations and was considering forwarding them all to one domain directly would greatly benefit ranking. The blogs are all linked together and that is where most of the links come from. Would I benefit in 301 Redirecting the domains?
Intermediate & Advanced SEO | | WindshieldGuy-2762210 -
How to Redirect
What is the htaccess code to redirect everything in a directory to a file? Thanks!
Intermediate & Advanced SEO | | tylerfraser0 -
Need some help with a tricky 301
I can't find anything online that deals with this issue. I have a page getting indexed by Google at mydomain.com/widgets and I don't know why. No links to it anywhere. The page it is closest to is mydomain.com/reviews/widgets and so I tried to set up a 301 to point one to the other. The problem is each individual widget review is at mydomain.com/widgets/reviews/products/widget-name and so when I redirect /widgets to mydomain.com/reviews/widgets it also redirects each individual product to mydomain.com/reviews/widgets/reviews/products/widget-name. Is there some way to just redirect /widgets without having it affect each product review? I cannot change URL structure either, nature of the site. Any ideas?
Intermediate & Advanced SEO | | DanDeceuster0