Htaccess redirects
-
Annoyingly it's time to play with this beast again.
I've been given the task of doing the following.
Keeping the homepage live
Redirecting categories to the specific categories on the new site
Catch all redirects
Now i've managed to setup the specific categories and the catch all redirects, however I am unsure how to keep the homepage live (which is like this:www.domain.com/ so I can't just exclude that?)
Would appreciate any help.
-
If I have understood it correctly, you want:
- To redirect certain category pages to new category pages on a new domain.
- Redirect all other pages to the homepage on a new domain
- Not to redirect the homepage and for that to stay on the current domain.
If so I think this should probably do what you want:
RewriteRule ^$ - [L]
RewriteRule categoryA/ http://www.newdomain.com/newcategoryA/ [R=301,L]
RewriteRule (.+) http://www.newdomain.com/ [R=301,L]The first rule says "if this is the homepage stop evaluating rules". The second maps a category page over to the new version and stops evaluating rules; you'll need to duplicate this one for all the specific categories. The last rule is your catch-all rule for redirecting everything else to the homepage of the new domain.
If you want to easily test/check then I highly recommend this .htaccess checker tool.
Good luck!
-
Got around this by adding catch alls for a-z/0-9.
RewriteRule ^a(.*) http://www.domain.com? [R=301,NE,NC,L]
This meant that the homepage wasn't being touched. However I did lose all of the category specific redirects. I'm sure there was a way around this however I don't know htaccess to do this well enough. Would be interesting if anyone would know how to do all three?
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
-
Can i do 301 redirect
So this is what im doing, 301 redirect to my site/allen-webdesign points to main domain Allen is the city i have a page called local-webdesign with all the cities. Will this improve my ranking or should i stop?
Technical SEO | | jsdfw0 -
Redirect non slash to slash
Hello SEO gurus We have an issue here ( www.xyz.com.au) is having 200 responses www.xyz.com.au and www.xyz.com.au/ ( when i ran the crawl test i found this ) We have been advised to do a 301 from non slash to slash ( as our other pages are showing up with slash ) for the consistency we decided to go with this but our devs just couldnt do it. Error is - redirect loop and this site is a wordpress one Can anyone help us with this issue? Help is much appreciated.
Technical SEO | | Pack0 -
301 redirects without .htaccess
I have a client that recently moved from an old ZenCart e-commerce site to Volusion. The domain name did not change. We need to redirect a bunch of the old URLs; however, Volusion's redirect tool does not work for URLS with "?" . The old ZenCart structure is: http://www.mydomain.com/index.php?main_page=product_info&products_id=563 Volusion is a hosted platform and we do not have access to the .htaccess file. Any suggestions on a workaround? Thanks!Nancy <colgroup><col width="960"></colgroup>
Technical SEO | | NancyVPS
| |0 -
Help creating a 301 redirect in my htaccess file
Hi Guys, I'm trying to build a 301 file with the file requirements: It should be visible only for Google and other Search Engine Agents. It will have a few direct redirects. A few URL must be dynamic redirect. For example each page the starts with olddomain.com/category and is not in the list of of direct redirects should be redirect for newdomain.com/category Here is my start point: #301 Starts here Set the agents RewriteEngine On
Technical SEO | | Felip3
RewriteCond %{HTTP_USER_AGENT} Googlebot [OR]
RewriteCond %{HTTP_USER_AGENT} msnbot [OR]
RewriteCond %{HTTP_USER_AGENT} Slurp Make the direct redirect. Redirect 301 /category/sub1 http://www.newdomain.com/category/sub1
Redirect 301 /category/sub2 http://www.newdomain.com/category/sub2 Redirect everything else Redirect 301 /category/* http://www.newdomain.com/category #End of my 301 Will that work how I want? is there anything wrong?0 -
Trackback Redirects
My wordpress blog/theme displays a Trackback URL link in the comments area of any page that has received a comment, eg http://guitarkitbuilder.com/build-your-own-clone-digital-echo-ping-pong-kit/#comment-2408 My crawl diagnostics report shows these links (basically domain.com/post-name/trackback) as Temporary Redirect warnings 302 with the stock advice "Using HTTP header refreshes, 302, 303 or 307 redirects will cause search engine crawlers to treat the redirect as temporary and not pass any link juice (ranking power). We highly recommend that you replace temporary redirects with 301 redirects." Before I take more action on this I want to make sure this is a real problem. My initial effort to fix it was to turn off trackbacks in the wordpress settings-discussion area and also on specific posts, but the Trackback URL link still shows for any post with a comment. Any advice?
Technical SEO | | jeff_amm0 -
301 redirect of a subdirectory
Hello! I am working on a website with the following structure: example.com/sub1/sub2/sub3. The page "example.com/sub1" does not exist (I know this is not the optimal architecture to have this be a nonexistent page). But someone might type that address, so I would like it to redirect it to example.com/sub1/sub2/sub3. I tried the following redirect: redirect 301 /sub1 http://example.com/sub1/sub2/sub3. But with this redirect in place, if I go to example.com/sub1, I get redirected to example.com/sub1/sub2/sub3/sub2/sub3 (the redirect just inserts extra subdirectories). If someone types "example.com/sub1" into a browser, I would "example.com/sub1/sub2/sub3" to come up. Is this possible? Thank you!
Technical SEO | | nyc-seo0 -
302 redirects help
Hello, I have a Magento ecommerce store and my latest seomoz crawl report shows over 10,000 302 redirects. An example is this below https://jsshirts.com.au/wishlist/index/add/product/160/ which is being redirected to http://jsshirts.com.au/enable-cookies Can anyone please help me with a solution to help with this problem. Many thanks
Technical SEO | | mullsey0 -
Code for redirect
What is the code to redirect www.xyz.com/abc where abc is a folder to www.xyz.com/abc.html
Technical SEO | | seoug_20050