301 Redirect To Corresponding Link No Matter The URL?
-
Hey guys
I have hosting on Host Gator with I believe an apache web server. I need a code to put in the HT ACCESS to redirect all WWW URL's to their corresponding http URL. I haven't been able to get a code to work.
For example, http://www.mysite.org/page1.html -> http://mysite.org/page1.html , without having to redirect hundreds of pages individually
Here is the format my server uses in the HT ACCESS file for 301 redirects.
RewriteCond %{HTTP_HOST} ^mysite.org$ [OR] RewriteCond %{HTTP_HOST} ^www.mysite.org
$RewriteRule ^Electric-Pressure-Cookers.html$ "http://mysite.org/Pressure-Cookers.html" [R=301,L]Thanks
-
Hey Andy,
Thanks a ton - now all my URL's are appearing as the http version - one problem remains, however, and that is that I can still access the WWW version. Trying to 301 all URL's to the http version but now part of the problem is fixed. Thanks a ton!
-
RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC] RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Andy
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
-
Will URLS With Existing 301 Redirects Be as Powerful As New URLS In Serps?
Most products on our site have redirects to them from years of switching platform and merely trying to get a great and optimised URL for SEO purposes. My question is this: If a product URL has alot of redirects (301's), would it be more beneficial to me to create a duplicated version of the product and start fresh with a new URL? I am not on here trying to gain backlinks but my site is tn nursery dot net (proof:)
Intermediate & Advanced SEO | | tammysons
I need some quality help figuring out what to do.
Tammy0 -
batch 301 redirects with an external tool
Hi, I am migrating my e-commerce to another platform of a internet company in Brazil (Tray) that has no way to redirect 301 urls in batch, I also do not have access to files and ftp of it. Anyway, as I have hundreds of urls, I would like to know if there is any way to do batch redirects with an external platform tool? Thank you very much in advance
Intermediate & Advanced SEO | | didi090 -
301 Redirect - Rank Recovery Examples?
Hi All, I recently did a 301 redirect. Page to Page and the notified google via its console. Its been 6 days since. The home page and one other high traffic page swopped out with the new domain on google search index with 3-4 drops in ranking for each. The rest of the sites pages have been indexed but still reflect the old domain when searched. Recently today my home page dropped even further to the second page of google index for the specific keyword. Can you share similar experiences and how long it took you to recover rank fully? and how long for all pages to swop out on google search's index? Regards Mike
Intermediate & Advanced SEO | | MikeBlue10 -
301 redirect hops from non-https and www
It's best practice to minimize the amount of 301 redirect hops. Ideally only one redirect hop. It's also best practice to 301 redirect (or at least canonical) your non-https and/or your non-www (or www) to the canonical protocol/subdomain. The simplest (and possibly the most common) way to implement canonical protocol/subdomain redirects is through a load balancer or before your app processes the request. Both of which will just blanket 301 to the canonical domain/protocol regardless if the path exists or not In which case, you could have: Two hops. i.e. hop #1 http://example.com/foo to https://example.com/foo, hop #2 https://example.com/foo to https://example.com/bar 301 to a 404. Let's say https://example.com/dog never existed, but somebody for whatever reason linked to it (maybe a typo). If I request https://www.example.com/dog, the load balancer would 301 to a 404 page. Either scenario above should be fairly rare. However, you can't control how people link to you. Should I care about either above scenario? I could have my app attempt to check if the page exists before forwarding, but that code could be complicated.
Intermediate & Advanced SEO | | dsbud0 -
Does 302 redirects pass link juice ? - I've read conflicting reports
Hi Mozzers Ive noticed that I have some 302 redirects on my website which have been there for some time . They should really 301's but I am wondering if 302s pass link juice or not as from what I've read they don't so I just wanted to check if anyone knew for sure, thanks pete
Intermediate & Advanced SEO | | PeteC120 -
Is This 301 redirection correct??
Hello Everyone, I have Added This in .htaccess. Options +FollowSymlinks
Intermediate & Advanced SEO | | falguniinnovative
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule (.*) http://www.domain.com/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^./index.html
RewriteRule ^(.)index.html$ http://www.domain.com/$1 [R=301,L] ErrorDocument 404 /index.html Is this Correct ?? or need any change, please help, thanx in advace .0 -
Redirect 1 specific link from a referrer, wise move?
This might be a bit of a complex question as it has many implications and I’d really appreciate some expert advice. I have a client who has one specific .gov link which is absolutely amazing. It doesn’t have any anchor text and goes straight to the homepage. However it drives quite a lot of revenue! It’s lovely as SEO’s to think of links actually driving revenue rather than assisting rankings of course. Over the last 30 days this single govt. link has driven: 418 clicks, 61 conversions, $7,500 revenue Not bad I hear you say! J I really want to extract maximum value from this and I’ sure it would perform far better if it went to a really tightly focused landing page rather than the homepage. It really is hyper-targeted buyer traffic (as the stats show) but could perform even better in my opinion. I can’t change the link, that’s not possible unfortunately. However I can do some server side stuff to redirect traffic from just this link to a desired new page. However, what are the SEO implications of this in the opinion of some of the experts here? Obviously the link itself is valuable from an SEO perspective and I don’t want to lose that. I’m not sure how Google would treat the link if this were to be done. Also I really want to A/B test the homepage versus a landing page to ensure that it really does give an improvement. I’m not even sure how to achieve that given the difficulty in this situation. Any advice would really be useful! Thanks J
Intermediate & Advanced SEO | | HarveyP0 -
What are your thoughts on using Dripable, VitaRank, or similar service to build URL links too dilute link profile???
One of my sites has a very spamy link profile, top 20 anchors are money keywords. What are your thoughts on using Dripable, VitaRank, or similar service to help dilute the link profile by building links with URLs, Click Here, more Info, etc. I have been building URL links already, but due to the site age(over 12 years) the amount of exact match anchor text links is just very large and would take forever to get diluted.
Intermediate & Advanced SEO | | 858-SEO0