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
-
Internal Links - Different URLs
Hey so, In my product page, I have recommended products at the bottom. The issue is that those recommended products have long parameters such as sitename.com/product-xy-z/https%3A%2F%2Fwww.google.co&srcType=dp_recs The reason why it has that long parameter is due to tracking purposes (internally with the dev and UX team). My question is, should I replace it with the clean URL or as long as it has the canonical tag, it should be okay to have such a long parameter? I would think clean URL would help with internal links and what not...but if it already has a canonical tag would it help? Another issue is that the URL is different and not just the parameter. For instance..the canonical URL is sitename.com/productname-xyz/ and so the internal link used on the product page (same exact page just different URL with parameter) sitename.com/xyz/https%3A%2F%2Fwww.google.co&srcType=dp_recs (missing product name), BUT still has the canonical tag!
Intermediate & Advanced SEO | | ggpaul5620 -
How long should I keep the 301 redirect file
We've setup an new site and many pages don't exist anymore (clean up done). But for many of them we have new pages with new url's. We've monitored the 404 and have now many URL's redirected with 301 (apache file). How long should we keep this in place? Checking all links manually to see of new url is in place of the old url (in google) is too much work. tx!
Intermediate & Advanced SEO | | KBC0 -
301 Redirect from unused domain
Hi All First question here so go easy.. I have a property site which is working well so far considering it;s early days, unfortunately some of my earlier efforts did not go so well and one in particular I pretty much destroyed in my attempts to improve the site SEO. Lucky enough my SEO skills have improved quite a bit lately, largely thanks to the great tools, tutorials and experts here at Moz 🙂 My question is whether I can use a 301 redirect to pass the domain authority and any link equity from an unused site to the one that ive done a better job on? it would seem a little sketchy to me and I would prefer not to get slapped and penalized "again" for doing something dodgy... Thanks everyone and thanks for all the help over the last 6 months or so.. Wes Dunn
Intermediate & Advanced SEO | | wesdunn19771 -
Dealing with Penguin: Changing URL instead of removing links
I have some links pointing to categories from article directories, web directories, and a few blogs. We are talking about 20-30 links in total. They are less than 5% of the links to my site (counting unique domains). I either haven't been able to make contact with webmasters, or they are asking money to remove the links. If I simply rename the URL (for example changing mysite.com/t-shirt.html to mysite.com/tshirts.html), will that resolve any penguin issues? The link will forward to the homepage since that page no longer exists. I really want to avoid using the disavow tool if possible. I appreciate the feedback. If you have actually done this, please share your experience.
Intermediate & Advanced SEO | | inhouseseo0 -
Duplicate content reported on WMT for 301 redirected content
We had to 301 redirect a large number of URL's. Not Google WMT is telling me that we are having tons of duplicate page titles. When I looked into the specific URL's I realized that Google is listing an old URL's and the 301 redirected new URL as the source of the duplicate content. I confirmed the 301 redirect by using a server header tool to check the correct implementation of the 301 redirect from the old to the new URL. Question: Why is Google Webmaster Tool reporting duplicated content for these pages?
Intermediate & Advanced SEO | | SEOAccount320 -
Canonical or 301 redirect, that is the question?
So my site has duplicate content issues because of the index.html and the www and non www version of the site. What's the best way to deal with this without htaccess? Is it a 301 redirect or is it the canonical, or is it both?
Intermediate & Advanced SEO | | bronxpad0 -
Is it ok to use both 301 redirect and rel="canonical' at the same time?
Hi everyone, I'm sorry if this has been asked before. I just wasn't able to find a response in previous questions. To fix the problems in our website regarding duplication I have the possibility to set up 301's and, at the same time, modify our CMS so that it automatically sets a rel="canonical" tag for every page that is generated. Would it be a problem to have both methods set up? Is it a problem to have a on a page that is redirecting to another one? Is it advisable to have a rel="canonical" tag on every single page? Thanks for reading!
Intermediate & Advanced SEO | | SDLOnlineChannel0 -
It Doesn’t Matter Where You Point Links, Google Will Pick The Page
Hi Guys, I have a site that ranks quite well in a very competitive vertical and the company is now planning to do a site relaunch. SEO is very important to them and all of the sites within in the top 10 have the primary keyword in the urls example search: key1 key2 site.com/key1-key2/
Intermediate & Advanced SEO | | VividLime
site.com/ key1key2/
site.com/key1key2.php Our site is the only one that is positioned within the top 10 without the keyword in the url and homepage only listing so the top 10 result looks like search: key1 key2 site.com/key1-key2/ site.com/ key1key2/ site.com/key1key2.php oursite.com sitekey2.com/key1-key2/
key1site.com/key1key2.html Currently we do not have a separate landing page for the target keyword hence why link building is focused on the homepage. As part of the consultation, I recommended we create a landing page for our primary keyword so we get **oursite.com/key1-key2/ **and shift the on-page keyword balance towards this page. the hope is, we get search: key1 key2 site.com/key1-key2/ site.com/ key1key2/ site.com/key1key2.php oursite.com/key1-key2 sitekey2.com/key1-key2/
key1site.com/key1key2.html Would Google simply replace my current domain only list for the most relevant url for a term? Does anyone have any experience with this? Or would i need to build links into the new url for the change to take place. what i'm hoping for and expecting, is for somthing like this to happen http://www.seowizz.net/2011/04/it-doesnt-matter-where-you-point-links-google-will-pick-the-page.html0