Htaccess Issue: URL not resolving properly
-
I am merging a niche site, tshirts.com to another site mainsite.com.
I am using an htaccess file on a linux server, and the homepage of the niche site is being directed to the corresponding category page on the main site (i.e nichesite.com to mainsite.com/niche.html). Everything else is also a page to page redirect.
I have something like this in the htaccess file:
Redirect 301 http://tshirts.com/ http://www.mainsite.com/tshirts.html
Redirect 301 http://tshirts.com/blue.html http://www.lampclick.com/blue-t-shirts.html
Redirect 301 http://tshirts.com/white.html http://www.mainsite.com/white-t-shirts.html
Redirect 301 http://tshirts.com/black-tshirts.html http://www.mainsite.com/bk-t-shirts.htmlWhen I check 301 for lets say http://tshirts.com/blue.html, I get:
http://tshirts.com/blue.html -** 301 Moved Permanently**
http://www.mainsite.com/tshirts.htmlblue.html -** 302 Found**
http:www.mainsite.com/
How do I fix this? Why is everything being appended to minsite/tshirts.html?
I appreciate your help.
-
The problem is the order here. Remember that redirects fire from top down. In this case, you're telling it to redirect the main page, then redirect the secondary page, so what you get is / redirects to http://www.mainsite.com/tshirts.html and then it tries to redirect /blue.html but it's already done the previous redirect, so it tries to append blue.html to this and you end up with what you did, http://www.mainsite.com/tshirts.htmlblue.html
-
Hi there,
Redirects should always be written in a relative to absolute path.
So the .htaccess file for http://tshirts.com/ should contain something like:
Redirect 301 / http://www.mainsite.com/tshirts.html
Redirect 301 /blue.html http://www.lampclick.com/blue-t-shirts.html
Redirect 301 /white.html http://www.mainsite.com/white-t-shirts.html
Redirect 301 /black-tshirts.html http://www.mainsite.com/bk-t-shirts.htmlI think that should solve the issue.
Keszi
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
-
How should you determine the preferred URL structure?
Hi Guys, When migrating to a new CMS which include new pages how should you determine the URL structure, specifically: So should we include www. or without it? Should the URL have a trailing slash? How would you determine the answer to these questions? Cheers.
Intermediate & Advanced SEO | | kayl870 -
Solving pagination issues for e-commerce
I would like to ask about a technical SEO issue that may cause duplicate content/crawling issues. For pagination, how the rel=canonical, rel="prev" rel="next" and noindex tag should be implemented. Should all three be within the same page source? Say for example, for one particular category we may have 10 pages of products (product catalogues). So we should noindex page 2 onwards, rel canonical it back to the first page and also rel="prev" and rel="next" each page so Google can understand they contain multiple pages. If we index these multiple pages it will cause duplicate content issues. But I'm not sure whether all 3 tags need adding. It's also my understanding that the search results should be noindexed as it does not provide much value as an entry point in search engines.
Intermediate & Advanced SEO | | Jseddon920 -
URL Formatting - Magento
Hi, We are working with a client on Mangento who URLs are formatting Google friendly eg; productname.html - as seen in site search in Google) but when you click the link to the site it is adding on #.VEWKQxbc754 (or similar) The site is also having some page indexing problems as well Thoughts? specific settings/Add on in magento?
Intermediate & Advanced SEO | | Pure-SEO0 -
Htaccess rewrite rule (very specific)
Hello, Awhile back my company changed from http: to https: sitewide (before i started working here). We use a very standard rewrite rule that looks like this: RewriteEngine On
Intermediate & Advanced SEO | | Waismann
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://opiates.com/$1 [R,L] However, with this rule in place, some http: urls are being redirected with a 302 status code. My question is, can I safely change the above code to look like this: RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://opiates.com/$1 [R=301,L] to ensure that every redirected is returned with a 301 status code. The only change is in the [R,L] section. Thanks to whomever can help with this. I'm pretty sure its safe but I dont want the site to go down, even for a second, so figured I would ask first.0 -
SEO within the URL /
If I were optimizing for 'marketing success' and my URL structure was domain.com/marketing/success would that count? I'm not sure if the '/' affects the keyword term. My assumption is that it does, but I wasn't 100% sure. Thanks!
Intermediate & Advanced SEO | | KristinaWitmer0 -
Duplicate Content Issue
Why do URL with .html or index.php at the end are annoying to the search engine? I heard it can create some duplicate content but I have no idea why? Could someone explain me why is that so? Thank you
Intermediate & Advanced SEO | | Ideas-Money-Art0 -
We are changing ?page= dynamic url's to /page/ static urls. Will this hurt the progress we have made with the pages using dynamic addresses?
Question about changing url from dynamic to static to improve SEO but concern about hurting progress made so far.
Intermediate & Advanced SEO | | h3counsel0 -
Limiting URLS in the HTML Sitemap?
So I started making a sitemap for our new golf site, which has quite a few "low level" pages (about 100 for the golf courses that exist in the area, and then about 50 for course architects), etc etc. My question/open discussion is simple. In a sitemap that already has about 50 links, should we include these other low level 150 links? Of course, the link to the "Golf Courses" is there, along with a link to the "Course Architects" MAIN pages (which, subdivides on THOSE pages.) I have read the limit is around 150 links on the sitemap.html page and while it would be nice to rank long tail for the Golf Courses. All in all, our site architecture itself is easily crawlable as well. So the main question is just to include ALL the links or just the main ones? Thoughts?
Intermediate & Advanced SEO | | JamesO0