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
-
Redirect chains and rankings
Hi All, I've got interesting question for Moz community today. Has redirect chain got any impact on rankings or not? Thank you in advance.
On-Page Optimization | | Optimal_Strategies0 -
Internal Linking : File Name or URI/filename.html
Hi, For crawlability, what would be the best way to do internal linking. /aboutus.html or www.xyz.com/aboutus.com Would this make any difference to the website in terms of SEO or bot crawling the website? Regards, Sree
On-Page Optimization | | jungleegames0 -
"translation" of code in htaccess file
Hi everyone! I am a newbie to the whole SEO and html thing and I am trying to get a better understanding of the "behind the scenes" part of my website. I hope I can find someone here who can translate a piece of code for me that I have in my htaccess file: Options -Multiviews
On-Page Optimization | | momof4
Options +FollowSymLinks
rewritecond $1 !^(index.php|public|tmp|robots.txt|template.html|favicon.ico|images|css|uploads)
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewriterule ^(.*)$ index.php?link=$1 [NC,L,QSA] I know that something is getting redirected to the index file, but what (or when) exactly? Does the word "robots"mean that search engine crawlers are getting redirected here? And is this good or bad (in terms of SEO)? Or is this redirecting people who try to get to my robots/ template or image files?? Thanks in advance for any answers!0 -
Tech/Development Pricing ??
Hi I've submitted some site change request to a clients dev team and they have got back with a rather large quote thats left me gobsmacked, so i want to run it by any of you to get your feedback ? Creating/integrating a dynamic xml site map @ £3450 Fixing Crawl Errors & Warning reported by Moz report (i..e adding canonicalisation tag to each page to deal with dupe content and a few other small/misc items) @ £4850 Setting up/enabling ecom tracking in Analytics @ £910 Setting up 1 events based goal in analytics @ £490 Are these prices even plausible ? Cheers Dan
On-Page Optimization | | Dan-Lawrence0 -
Help! A site has copied my blog!
My site tanked on July 21 and I have been working so hard to bring it back up but nothing is working. Today I looked at "Links to Your Site" on Google Webmasters and I see a copy of my site on another URL. mysite.eemovies.org/mycategory/mypost The domain name is eemovies.org and then all my stuff is wrapped around it and all my content is there! How do I stop this?!
On-Page Optimization | | 2bloggers0 -
Redoing a site - 404 redirect or 301 redirect
I'm redoing a website, should i 404 the old pages, or 301 redirect to the main page? what is better? (around 100 pages)
On-Page Optimization | | mkmedia0 -
H1 Tags for Articles in Blog Category - confused ;-(
Dear Seomoz community This is my first post here. Until now I was only browsing the Q&A and learned a lot just by reading the existing topics. Since we launched our website with a new design last week I started to heavily use Seomoz to track down missing tags, descriptions and other on page issues. Just out of curiosity I checked the page outline of the Seomoz blog. I was really surprised! Seomoz uses only H1 tags on their blog main page. Each article is wrapped in an H1 plus the blog title. I am a total SEO beginner but until today I was thinking that using several H1 tags on one page is not optimal. We use one H1 tag on our site for the magazine category description (for example http://www.siam2nite.com/magazine ) and then for the articles H2. So my question. Should I change my H2 to H1 for the magazine articles like Seomoz did? Would really appreciate your advise on this Regards, Menelik
On-Page Optimization | | menelik0 -
New Site + Transfered blog: Things to watch for?
Hey everyone. So here is what's going on. 1. Built new website. Will be using generally the same URL's as original. 2. Incorporated and expanded on a previously separate informative blog. a. Many articles contain very similar if not the same articles as our blog. 3. The blog will be taken down as soon as new site is put online. So my question is just. Could someone list the like top 5 important things I need to keep in mind before putting this website live? I don't mind searching forums and blogs for the how-to part; I just need to know what I should be thinking about and getting done pre-launch. I believe re-directing the blog articles should be done? Create and submit sitemap? Thanks, Web-creation newb
On-Page Optimization | | Earthsaver0