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
-
Do Blog Tags affect SEO at all anymore?
We're trying to standardize the use of tags on our site amongst writers/editors, and I'm trying to come up a list of tags they can choose from to tag posts with - and telling them to use no more than 10 (absolute maximum) per post. We are also in the process of migrating to a new CMS, and have 8 defined categories that will all have their own landing page within our "News" section. TLDR: Do blog tags have any impact on SEO anymore? Are they solely meant to help users find articles related on popular topics, or does creating a tag for a popular topic help to improve organic visibility? Full Question: With the tag standardization, I want to make sure we're creating the most useful and effective tags; and the UX/SEO sides of my brain are conflicted. To my understanding, creating a tag about a high volume topic in an industry helps establish the website's relevance to Google/other search engines about that topic and improves overall relevance; but the tag feed page (ex: http://freshome.com/tag/home-protection/) isn't really meant for organic search visibility. So my other question is, is it worth it to noindex the tag pages in the robots.txt? Will that affect any benefit to increased relevance for Google (if there is any)? I'm interested to hear others' thoughts and suggestions. Thanks in advance!
On-Page Optimization | | davidkaralisjr0 -
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 -
Help with Temporary Redirects on Pages
Hi Guys, My latest crawl shows this: "44% of site pages served 302 redirects during the last crawl" When I click this to investigate the issue I see: URL:
On-Page Optimization | | jeeyer
https://www.....
https://www.....
https://www.....
https://www.....
https://www..... And under Redirect URL:
http://www....
http://www....
http://www.... I've recently read an article from Yoast that this is a https:// to http:// redirect (ofcourse 😉 ).
but why is this an issue that needs to be solved and how do I solved it? Thanks again for your help and thoughts. Joost0 -
Will changing a site from https to normal http have any SEO impact if we do automatic redirects?
We currently have a site which uses https and want to change to normal http only (for reasons unrelated to SEO). We were planning to do this with a change in our server configuration (we use Nginx, and can automatically redirect https to http). Our site has been around for approx 1 year, so there are links floating around in the Internet which will still be using https. These will be automatically redirected to http. What will be the impact on our SEO? I understand that our webmaster tools account may need to change...
On-Page Optimization | | michaelcho0 -
Best way to separate blogs, media coverage, and press releases on WordPress?
I'm curious what some of your thoughts are on the best way to handle the separation of blog posts, from press releases stories, from media coverage. With 1 WordPress installation, we're obviously utilizing the Posts for these types of content. It seems obvious to put press releases into a "press release" category and media coverage into a "media coverage" category.... but then what about blog posts? We could put blog posts into a "blog" category, but I hate that. And what about actual blog categories? I tried making sub-categories for the blog category which seemed like it was going to work, until the breadcrumbs looked all crazy. Example: Homepage > Blog > Blog > Sub-Category Homepage = http://www.example.com First 'Blog' = http://www.example.com/blog Second 'Blog' = http://www.example.com/category/blog Sub-Category = http://www.example.com/category/blog/sub-category This just doesn't seem very clean and I feel like there has to be a better solution to this. What about post types? I've never really worked with them. Is that the solution to my woes? All suggestions are welcome! EDIT: I should add that we would like the URL to contain /blog/ for blog posts /media-coverage/ for media coverage, and /press-releases/ for press releases. For blog posts, we don't want the sub-category to be in the URL.
On-Page Optimization | | Philip-DiPatrizio0 -
Total Links has doubled in less than one month!? Trust and Authority Drop
Hey Guys, Our website has just recently started to manage our website with SEO in mind and there are a few things that I am concerned about. 1. Domain authority, moztrust, mozrank have been dropping. 2. We had 368k links on 6/27 and on 7/11 we had 563k Is this a result of confusion between our www.websitenamehere.com and websitenamehere.com?
On-Page Optimization | | briggsb0 -
Looking to Buy a New Domain for 10 Years
I want to Know, for how much year i should buy a new domain for optimal SEO Results. Should I Buy it for 3 Years, 5 Years or 10 Years
On-Page Optimization | | Ganesh340 -
Do Blog Comments On Your Site Help SEO?
There is a lot of debate as whether or not having comments on your blog is helpful from an SEO perspective. Proponents believe that more comments (1) creates more content, which search engines love, (2) creates more relevant keywords that can be searched, and (3) helps with "freshness" of the site/content leading to greater site authority. Others like Joost de Valk believe that comments can actually hurt SEO because keyword density cannot be controlled. He argues that his top SEO content are pages not posts for this very reason. What is your opinion?
On-Page Optimization | | marcperry0