Help Needed With .htaccess RewriteRule
-
Hello Fellow Mozzers,
I would really appreciate a little help as I have been banging my head against a wall for the last few hours trying to create a .htaccess RewriteRule.
I have around 300 URLs that I need to 301 redirect following a site re-build, they are in groups of similar urls but infortunately not broken down in to folders.
Here is an example of a few URLs:-
https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoodii_2.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoodii-200225cm-6670.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoodii.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoods-gold.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-lemon-queen.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-yvonne-200cm-66.htmAll of the above URLs need to redirect to a new URL:-
http://www.domain.co.uk/chamaecyparis-lawsoniana
Here is the RewriteRule that I currently have but it isn't working:-
RewriteEngine On
RewriteRule ^(.*)_chamaecyparis-lawsoniana$ https://www.domain.co.uk/chamaecyparis-lawsoniana [R=301,L]Anyone have any suggestions?
Thanks
Ade. -
Thanks Jaspal, works perfectly.
Yes we did meet at LinkLove and hopefully will do again at the next one as I now owe you a beer!
Much appreciated.
Ade. -
Hi Ade, didn't we meet up at LinkLove? Hope things are going well.
Try this:
RewriteRule ^chamaecyparis-lawsoniana-.+ https://www.domain.co.uk/chamaecyparis-lawsoniana [R=301,L]
The underscore was a problem as was the $ at the end
using -.+ at the end to avoid matching the target url
I tried that with regexr and it seems to work ok, not used it in an htaccess
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
-
301 redirection help needed!
Hi all, So if we used to have a domain (let's say olddomain.com) and we had a new site created at newdomain.com how do we properly setup redirects page to page. Caveat, the urls have changed so for instance the old page oldomain.com/service is now newdomain.com/our-services on the new site. Do we need to have hosting on the old site? Do we need to setup individual 301s for each page corresponding to the new page? Just looking for the easiest way to do this CORRECTLY. Thanks, Ricky
Intermediate & Advanced SEO | | RickyShockley3 -
Do I need to remove pages that don't get any traffic from the index?
Hi, Do I need to remove pages that don't get any traffic from the index? Thanks Roy
Intermediate & Advanced SEO | | kadut1 -
My client wants to change domain name... Redirect help!
Hello, I have a client who wants to change domain names. The site is designed using WordPress, there are many plugins that will redirect links but they have to be same domain links. When I change the domain I would like to redirect all the old links to the same pages on the new url. How do I accomplish this? The plugin redirection or Yoast will not allow a redirect from one domain to another. Thanks for any help on this matter. I have 200+ Urls to redirect.
Intermediate & Advanced SEO | | donsilvernail0 -
Website/SEO Audit Needed
We've been outsourcing our link building to India for the past 3 years and the results were pretty good up until beginning of this year. What they were essentially doing is putting links into directories, a few per month, and posting a few articles per month. Out of our top 10 keywords, 8 got into top 10. Then something happened around Jan 1 last year, our ranking started dropping, falling out of the top 50, before settling around 20-30ish. We disavowed most of the low quality links since then. Also, very odd, all the top ranking competitors all fell (including me) and were replaced by less "specialized" companies who sold a broad range of products (for example: all parts of the car, rather than someone who just focused on mufflers). Theres also other differences but again I can't put a finger on it. I'd like to find someone who can do a detailed audit of our site, and our competitors, what happened to cause the drop, and why the new top positions sites are ranked high. And I really don't have time to do an audit myself. Our site is American Hospitality Furniture dot com. Any feed back would be appreciated. Thanks in advance.
Intermediate & Advanced SEO | | AHH8880 -
Robot.txt help
Hi, We have a blog that is killing our SEO. We need to Disallow Disallow: /Blog/?tag*
Intermediate & Advanced SEO | | Studio33
Disallow: /Blog/?page*
Disallow: /Blog/category/*
Disallow: /Blog/author/*
Disallow: /Blog/archive/*
Disallow: /Blog/Account/.
Disallow: /Blog/search*
Disallow: /Blog/search.aspx
Disallow: /Blog/error404.aspx
Disallow: /Blog/archive*
Disallow: /Blog/archive.aspx
Disallow: /Blog/sitemap.axd
Disallow: /Blog/post.aspx But Allow everything below /Blog/Post The disallow list seems to keep growing as we find issues. So rather than adding in to our Robot.txt all the areas to disallow. Is there a way to easily just say Allow /Blog/Post and ignore the rest. How do we do that in Robot.txt Thanks0 -
Silo Architecture - need an expert's advice
I understand the concept of silo architecture. What I don't understand is how to build the site navigation. I see experts talking about silos, but their sites have pervasive top level navigation. In theory, your top level nav breaks your silos. If I have 20 pages of supporting content all linked to my silo page, and the top nav is on the supporting content pages, then those pages all link to the pages in the top nav - silo broken, and link juice diluted. it would seem to me that the only way to build a true silo is to strip out all of the navigation on a supporting page, and only have it link to: 1. The silo landing page 2. Other supporting pages in the silo. is this what Bruce Clay does? I've seen Rand's lectures on silos as well. Is this what he is doing? I recently saw a video by the Network Empire team, and they'd also have a pervasive nav. Can someone please explain this?
Intermediate & Advanced SEO | | CsmBill0 -
Mobile SEO? Do we need it or not?
Hi Guys, I am about to start to redesigning a new mobile website and am curious if mobile SEO is actually having an affect or not. The site I am doing the redesign for, already has a very well optimized desktop site and has an existing mobile website with no optimization. The mobile website is ranking well in Mobile search so I am curious why I I would need to optimize the new mobile website properly, especially when the mobile website has a canonical tag for its desktop counter part? Love to get everyone's thoughts on this & where they see mobile SEO going in the next 12 months.
Intermediate & Advanced SEO | | seekjobs0 -
Hierachy in a Title Tag Needed?
When coding the title tags of a website, is it important to note the hierarchy of the website so the search engine can find that page? So, for example, the title tag would be, for a subcategory: Webpage Subcategory>Category>Website name Does this help the search engine rankings at all? Or can the search engines figure out the hierarchy by reading a sitemap or the HTML readable navigation? Then you could focus on the descriptive keywords of the subcategory page for the title tag. Also, should you always include the site name in the title tag?
Intermediate & Advanced SEO | | ConnellyPartners0