Htaccess redirect, from /year/month to /blog
-
I am trying to make some redirects so we don't lose that SEO juice.
I am trying to move our blog structure from:
http://www.domain.com/2015/09/title-of-blogto:
http://www.domain.com/blog/title-of-blogI need to do redirects in htaccess from the old structure to the new structure but I can't seem to get it working properly. Here is what I have thus far.
<code>RewriteEngine on RewriteBase / RewriteRule ^(.0-9)\/^(.0-9)\$ $1/ [R=301,L]</code>
Any suggestions?
-
This is the right answer minus a few excess characters.
If the blog structure is domain.com/2015/09/title-of-blog then the correct code would be as follows:
RewriteEngine On
RewriteBase /
RewriteRule ^[0-9]+/[0-9]+/(.*)$ blog/$1 [R=301,L]This will result in: domain.com/blog/title-of-blog.
In other words, Peter you had it right but you just had a few extra characters (you assumed the specific day was also included in the URL structure). Yours would work perfectly if the URL structure was domain.com/2015/09/02/title-of-blog
Also, if anyone ever wants to test your rewrite rules this is a great tool. http://htaccess.mwl.be/.
-
Correct code should be:
RewriteEngine On
RewriteBase /
RewriteRule ^[0-9]+/[0-9]+/[0-9]+/(.*)$ blog/$1 [R=301,L]
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
-
What to do with blog content that is no longer relevant to our business
We are a marketing agency and we have LOTS of blog posts still on our website from when we used to specialize in e-commerce services. We've since shifted There are a lot of old and frankly irrelevant blog posts on our website. My questions: Should we remove these from the website so better "shape" our content profile towards the services we actually offer? Should we attempt to update them so they are still relevant even though we don't offer those services? If we get rid of those pages, what should we redirect them to? The main blog page?
On-Page Optimization | | WhittingtonConsulting0 -
Can i use hard innerlinks on my blog to my landingspages ?
Hello, Ihave a website and also on the same domain a blog with a lot of posts. Is it possible in each blogpost put 2 innerlinks 1. innerlink to other blogpost with keyword or combination 2. hard link like "Design Sauna" and link to the landingspage of the webshop ? Is this the right way ? thanks 🙂 Regards, Marcel
On-Page Optimization | | Bossie720 -
Best Practice: Should We Always Make No-Follow for External Links from Blogs?
Hi Mozers, I have few questions: 1. If I am allowing advertising on my blog and people advertising by placing Ads, Contextual links in Posts, Should I make them No-Follow? If Yes, then I might lose a good amount of income coming from Advertising. What is the best practice without loosing Organic rankings. 2. If I make all the External Links No-Follow (simple wordpress plugin can do), then I may not have anyone to advertise on my blog. What is the advantage that I am going to get? 3. Keeping the Do-Follow on all external links, how it will effect my blog? when there is no spam and all quality content on the blog. Thank you
On-Page Optimization | | mutantspy0 -
Doubt about correct no. of categories on my blog
I have site wide 25 categories on my blog but I dont know whether I should keep few categories only like 6-8 or having 25 categories is ok? Plz help
On-Page Optimization | | ksbnok0 -
Do JSON feed / XML Feeds have any SEO benefits?
We are looking to use a 3rd party customer review provider and I have been told by their rep that it has a feature which allows us to display reviews placed with them about us on our website via JSON feed or XML feed (I have limited technical knowledge so have no idea what this is but am hoping our developer does!) I wanted to ask whether providing data in either format has any SEO benefits? My initial thoughts to provide customer reviews was to be useful to the customer and be useful for search engines as it will be continually updating user generated content (?) Any help on this would be greatly appreciated.
On-Page Optimization | | jannkuzel0 -
Recreate missing pages or just use 301 redirect?
Hi, on the Competitive Comparison section of the "link analysis" page the top 5 sites are linking to pages on my site that no longer exist. I'm wondering if it is worthwhile to recreate these pages that no longer exist or if I should just use a 301 redirect to some page on my site that has related info. Thanks for your suggestions.
On-Page Optimization | | PillarMarketing0 -
Is 302 Redirect a bad thing in SEO terms?
I am getting a lot of "302 (Temporary Redirects) = True" on many of my product URL's. What does it mean? Is it a bad thing to get these redirects? And how to fix them? Thanks.
On-Page Optimization | | SEOish0 -
Optimizing for Date Sensitive Products/Services
We have a product that we currently rank number one for, but would like to capture the date modified variations of the term (such as event 2011 or product 2012). My question is - what would be the best way to optimize for a date senstive product/service? Would it be better to include the date variation of the term on the main page for the product? Or should we create a new page entirely to capture this variation? I lean towards optimizing the existing page because the intent is the same whether a user is searching for product or product 2012. I should mention that the previous year versions of the product are not available. Merci. Chris Thompson
On-Page Optimization | | GroupPublishing0