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
-
Hi - How do you get rid of duplicate content that was accidentally created on a tag url? For example, when I published a new article, the content was duplicated on: /posts/tag/lead-generation/
the original article was created with: /posts/shippers-looking-for-freight-brokers/ How can I fix this so a new URL is not created every time I add a tag to a new posting?
On-Page Optimization | | treetopgrowthstrategy0 -
Duplicate content with a trailing slash /
Hi, I 've pages like this: A) www.example.com/file/ B) www.example.com/file Just two questions: Does Google see this as duplicate content? Best to 301 redirect B to A? Many thanks Richard PS I read previous threads re the subject, it sounded like there was a bug in SEOMoz but I was not absolutely clear. Apologies if this is going over old ground.
On-Page Optimization | | Richard5550 -
Blogs & CMS setup and integration
Hi Guys, I'm quite new to all things website wise. I understand the 'basics' of SEO (i think) and i'm alright with html but my experience stops there. Since i signed up to SEOMOZ, i've realised the importance of SEO and therefore our company has now employed 'an expert' to help us to go forward who happens to work for our web hosting company. Throughout the discussions, they strongly emphasised the importance of blogging and having a proper blog setup on our site and so we went along with the suggestion along with the SEO. Before we began, i went away and redesigned our site updating a lot of the content, the layout etc to basically give them a much better starting point because ultimately it would only benefit us. They have just started the work this month and to say i'm underwhelmed is an understatement!! With regards to the blog, as i didn't know what they were planning to do, i created three links at the bottom of our pages which looked like blog posts, a general blog page, and some blog posts which are all simple html pages. I assumed that they would then go away and create the blog thereselves and then obviously add it to our site. They have just come back now and said to me that as our site doesn't have a CMS, they will have to forward me the weekly posts and i will have to add them to the site myself and post them to our facebook and twitter pages. I am not particularly impressed with this as this is what we have paid just over £800 for which supposedly included them setting it up and managing it and did not include the SEO which is a lot of money for a small company as ourselves. What i wanted to know is that from our site as it stands now: http://www.customdesignedcable.co.uk, would it be difficult to include some sort of blog system that would integrate into our pages on the footer and the blog page or would i have to redesign the site through something such as joomla? I have never used joomla and i've only just found out that it exists. I'm asking on this forum as all of you guys know what your talking about and before i go back to them all guns blazing tomorrow, it would be great to be 'well up' on how difficult it would be and what the easiest ways would be to do it just to give me some ammo because i think they are talking out of there backsides! Any help you could give me would be greatly appreciated!! Big Thanks Guys!! I look forward to hearing from you. Chris.
On-Page Optimization | | Chris_CDC0 -
Will google see you bold/emphasis words if done in css?
We do not use header tags in our website. I understand bolding or emphsising words can be equally as effective but if done so in css will the google crawlers and spiders etc be able to put a weighted value on this style of code???
On-Page Optimization | | gsbureau0 -
If you were working on a wine site would you include the wine year in the URL?
I've come across a case where I'm asking myself what the best direction would be to go and while there is no right direction I would like to here some feedback from others. I'm working with some great content pages all about wine. As you probably know the difference between a 07 wine and a 95 is vastly different and up to this point I'm using the full year in the url much like this: grapesinyourtoesexample.com/2007-cellar-pod-viognier-adelaide-hills/. What I'm worried about is my use of the year in the URL. I feel it's very important for it to be used in the page title and on page but I'm concerned that it might be setting me back with my use of it in the url. My concern is that search engines might be interpretting it as a datestamp rather than as a informational piece of data describing the asset. Looking at my competitors, my content is one of the only sites using the year and in most searches for various wines my content is in the second half of the SERPs. If you were creating this content would you use the year? If you were working with current content would you drop the year across all of the site and implement to necessary redirects? Just to be clear this is a client related project so my use of "my site|my content" refers to the client's content.
On-Page Optimization | | DotCar0 -
Should I fix 302 redirects?
I have a Magento ecommerce site that allows customers to compare products. When SEOmoz crawled the site, it came back with over 6,000 302 redirect errors related to the compare products feature. Is this harming our rankings? And any suggestions on the best way to fix it?
On-Page Optimization | | AmazingPlans0 -
Blog content on homepage - Dupe Content Penalty?
Hi All, I am working on a website which has a blog at domain.com/blog/ On the homepage they are currently looping the latest 5 blog posts in a 'Latest News' tab. Is this therefore classed as dupe content, and would this be penalized by Google? Should I recommend they use the excerpts instead of full articles and simply loop the excerpts on the homepage? The website is built on WordPress. Thanks, Woody
On-Page Optimization | | seowoody1 -
301 redirect OK for a newer version of a page that is a different url?
I have about 500 products with multiple urls for the same product, but different versions. I sell wine and have a different page for each vintage. I've decided that is not the best way to go, and want to point the older vintage pages to the latest version page, and make that the only page for the product as time goes on. Do I have to put a link in the text from each older page to the newer, or can I use a 301 to redirect them to the new page? I don't want google to think I'm pulling something funny.
On-Page Optimization | | JeanYates0