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
-
Embedded twitter post is good for https://www.fitness-china.com/hip-thrust-machine seo
We have short video posts on twitter. Embedded twitter post is good for https://www.fitness-china.com/hip-thrust-machine SEO?
On-Page Optimization | | ahislop5740 -
Site Duplicated despte redirect
Buon pormeriggio from I can smell Whaler Chips Through the window Wetherby,
On-Page Optimization | | Nightwing
When you Google Thakray Medical Museum 2 sites appear in the SERPS, yikes! Now the .org site is no longer hosted & point to the .co.uk site when clicked on but in a nutshell I wantto get rid of the .org site
as illustrated here: http://s216.photobucket.com/user/zymurgy_bucket/media/two-versions-same-website-yikes_zps182e6e12.jpg.html Actions taken so far:
1: Wembaster tools re index request for the .co.uk site
2: Redirect configured to point .org site to the .co.uk What else is left apart from updating the xml site but ultimating i do not want to see the the .org site but it doesnt exist (well id did a few month back but is no longer hosted so i am told) Any insights welcome,
GRazie tanto,
David0 -
Keyword repeats/presence in url's & over-optimisation
Hi I'm about to launch a redesigned site and worried about overdoing kw presence on-page, primarily using in url's since will already be using kw in titles as well as page content. What's current thinking re over optimisation: If kw is in titles and page content is it best not to repeat again in url structure i.e. less is more, even though this will cause things like SeoMoz on-page grade score to fall, or better to keep them/add them ? Personally i think it makes sense to include kw in url again since helps make the page relevant, and so long as matches the content should help as opposed to hinder rankings for the pages target keyword. However when i look into this some say don't do this since is over-optimisation The sites generally ranking quite well for its target kw which i obviously don't want to lose after re-launch & hopefully improve further, in the case of this example they are 'Sports Centre Services' & 'Sports Centre Equipment Rental'). The sites current url structure is similar to this below example: frankssportscentres.com/services/sports-centre-equipment-rental Would it be better to keep following existing/above format or to go with either of the below options i.e. more kw rich urls or less: frankssportscentres.com/sports-centre-services/sports-centre-equipment-rental Or frankssportscentres.com/sports-centre-services/equipment-rental Or even less frankssportscentres.com/services/equipment-rental Many Thanks in advance for any helpful comments Cheers Dan
On-Page Optimization | | Dan-Lawrence0 -
Should I use this Facebook comment content on my related blog post?
I have a blog post that ranks pretty high for the term "justin bieber tickets". We are running a ticket giveaway and have received tons of responses on Facebook and G+. The responses are often poorly written in they sense that they are from younger fans, but it is a bunch of related content that I thought could be a "good "addition of unique content to the post. Is this a good idea in general? Is it still a good idea if the comments are poorly written and contain lots of slang an exclamation points? Is it bad form to put people's Facebook comments live on the web, even though it is a public page. Here is the post Example of what this would look like in the post >http://cl.ly/1Q3N0t091V0w3m2r442G Source of comments >http://www.facebook.com/SeatGeek Another less aggressive option would be to curate some of my favorite comments... Thanks for any thoughts.
On-Page Optimization | | chadburgess0 -
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 -
What's the Best Way to Hide Redirects from Search Engines?
Hey everybody, I like to use php redirects for affiliate links so they look better. I keep them all in the same directory. I read recently that these may hurt SEO. A couple quick questions: Is this the best way to redirect affiliate links? Should I simply block the directory in robots.txt? Any other suggestions from you SEO guyses and galz? Thanks! Jared
On-Page Optimization | | JaredB0 -
Login Page Redirection
Hello, I have certain pages on my site which are login only. Am wondering if a user reaches that page, should I send him to a 301 redirect to a new login page? or some other form of redirection? Any suggestions on how to best tackle this situation? Update If I redirect to a login.php page, then what kind of redirection should I use? Thank you for your time, Anant
On-Page Optimization | | anantgarg0 -
Social media links/buttons - best practices
Has anyone tested social media buttons, to see which types, styles, and placements get the most clicks? Should they go at the top of an article, or are they OK at the bottom? Should the icons definitely have labels? Display # of tweets and Likes? How big should they be? My preference is for discrete buttons with a smallish, plain icon and a label. I don't display tweets or Likes, unless it's a healthy number. And I still think a "share by email" icon is important. I put them at the bottom of the article, to keep the home page uncluttered and lead the eye into reading the article. I'm also concerned about leaking rank from the homepage, especially for a site that's still establishing itself. But if moving buttons to the top gets more shares, that's probably better. Is there a Wordpress plugin that you really like? (I haven't found one yet - I'm still hardcoding my social media buttons.) Opinions are great, but test results are better! Can anyone share?
On-Page Optimization | | mattotoole1