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
-
Need advice on overcoming a Google penalty
Here is the situation. Our website for our primary product (www.thetablift.com) has received a penalty by Google. Not long ago we had excellent rankings; (1st page) for some of our primary keywords, like "tablet stand". Now we are not in the index at all. Here is what happened (or at least what seems to have happened in my non-SEO opinion). Around October 2016, we had the "bright" idea to try and emulate a campaign that Eat 24 did, utilizing inexpensive traffic from advertisements on porn websites. The idea was a play on a joke we often hear about our product being perfect for certain activities where one needs to free one's hands while watching a screen. Of course this is not how we market our product (it is a best selling mainstream product), but we wanted to see if we could emulate the success of another mainstream brand that utilized this kind of non-mainstream advertising. The immediate result was a whole lot of traffic, but obviously the wrong kind, as it did not convert. So we pulled the plug after about 3 days. Flash forward several months later and we not only lost our great SEO rankings, but we were removed from Google's index entirely. I assume the reason for this is that somehow the website got dinged for being somehow related to porn. But of course it has nothing to do with that. So the question is: how do we go about getting un-penalized by Google? We had build up some solid SEO over the previous couple of years, and I'd like to get back to where we were, if possible. Oh, and this may or may not be relevant, but we also switched from www.tablift.com to www.thetablift.com a few months before we did this campaign. However, we used permanent redirects and did a textbook changeover, so I don't think that had any bearing. But I can't be sure. What are the steps to reverse this damage, if any? Thanks!
Intermediate & Advanced SEO | | csblev0 -
Do href lang tags need to be implemented at blogpost level?
Hey guys, Our site targets multiple territories. We use subfolders and hreflang tags on the site (built in WordPress) at a page level. We've added our hreflang tags manually in the section of each page. We're just re-doing the blog and we want to know if we need to add these tags to each individual blog post and if we do, how we would do it? Our developers have put them in at blog landing page level and told us that this will be fine. E.g.: /de/blog/ /gb/blog/ /uc/blog/ They have a slight tendency to push back on things though, and we just want to be sure we're doing this right. Hreflang tags are sooooo complicated so hoping you fine people can shed some light on the issue. Cheers!
Intermediate & Advanced SEO | | Twetman0 -
Need help in de-indexing URL parameters in my website.
Hi, Need some help.
Intermediate & Advanced SEO | | ImranZafar
So this is my website _https://www.memeraki.com/ _
If you hover over any of the products, there's a quick view option..that opens up a popup window of that product
That popup is triggered by this URL. _https://www.memeraki.com/products/never-alone?view=quick _
In the URL you can see the parameters "view=quick" which is infact responsible for the pop-up. The problem is that the google and even your Moz crawler is picking up this URL as a separate webpage, hence, resulting in crawl issues, like missing tags.
I've already used the webmaster tools to block the "view" parameter URLs in my website from indexing but it's not fixing the issue
Can someone please provide some insights as to how I can fix this?0 -
Help Dealing with Sustained Negative SEO Attack
Hello, I am hoping that someone is able to help with a problem that is destroying both my business and my health. We are an ecommerce site who have been trading since 2004 and who have always had strong rankings in Google. Unfortunately, over the past couple of months, these have significantly decreased (I would estimate around 40% drop in organic traffic). We have not had a manual penalty and still have decent rankings for a lot of competitive keywords, so we think it is more likely to be an algorithmic penalty.The most likely culprit is due to a huge scale negative SEO attack that has been going on for around 18 months. Last September, we suffered a major drop in rankings as a result of the 302 hijack scheme, but after submitting a disavow file (of around 500 domains) on 12th November, we recovered on 26th November (although we now don't know whether this was due to disavow file or the Phantom III update on 19th November).After suffering another major drop at the end of June, we submitted a disavow file of 1100 domains (this the scale of the problem!). This tempoarily halted the slide, however it is getting worse again. I have attached a file from Majestic which shows the increase in the backlinks (however we are not building these).We are at a loss and desperately need help. We have contacting all the sites to try and get links removed but they are happening faster than we can contact them. We have also done a full technical audit and added around 50,000 words of unique, handwritten content, as well as continuing to work through all technical fixes and improvements.At the moment, the only thing we can think of doing is submitting a weekly disavow for all the new spammy domains that come up. The questions I have are: Is there anything we can do to stop the attack? Is this increase in backlinks likely to be the culprit for the drops (both the big drops and the subsequent weekly 10% drop)? If so, would weekly disavows solve the problem? Is this likely to take months (years?) to recover from or can it be done quicker? Can you give me any ray of light to help me sleep at night? 😞 Really appreciate any and all help. I wouldn't wish ths on anyone.Thanks,Simon
Intermediate & Advanced SEO | | simonukss0 -
Htaccess Issue: URL not resolving properly
I am merging a niche site, tshirts.com to another site mainsite.com. I am using an htaccess file on a linux server, and the homepage of the niche site is being directed to the corresponding category page on the main site (i.e nichesite.com to mainsite.com/niche.html). Everything else is also a page to page redirect. I have something like this in the htaccess file: Redirect 301 http://tshirts.com/ http://www.mainsite.com/tshirts.html
Intermediate & Advanced SEO | | inhouseseo
Redirect 301 http://tshirts.com/blue.html http://www.lampclick.com/blue-t-shirts.html
Redirect 301 http://tshirts.com/white.html http://www.mainsite.com/white-t-shirts.html
Redirect 301 http://tshirts.com/black-tshirts.html http://www.mainsite.com/bk-t-shirts.html When I check 301 for lets say http://tshirts.com/blue.html, I get: http://tshirts.com/blue.html -** 301 Moved Permanently** http://www.mainsite.com/tshirts.htmlblue.html -** 302 Found** http:www.mainsite.com/ How do I fix this? Why is everything being appended to minsite/tshirts.html? I appreciate your help.0 -
Two identical websites need ranking locally
Hi Wondering if someone can advise. We have two websites with a .ie domian and .co.uk domain (e-commerce stores) The websites are identical so we need to address duplicate content issue. The issue we have is we are targeting both local Google to rank, google.ie and google.co.uk. Obviously to handle duplicate content we are going to have to "rel can" the one of the websites, which will probably be the .ie domain. Question is, will this effect the ranking within the .ie domian on google.ie. And any advice on how anyone else handles this situation would be greatly appreciated, we have had no issue ranking before with one domain on a local search engine, but this is the first time we have come across needing to rank two domains with identical content on each local search engine Thanks in advance John
Intermediate & Advanced SEO | | Johnny4B0 -
I can't help but think something is wrong with my SEO
So we re-launched our site about a month ago, and ever since we've seen a dramatic drop in search results (probably due to some errors that were made) when changing servers and permalink structure. But, I can't help but think something else is at play here. When we write something, I can check 24 hours later, and if I copy the Title verbatim, but we don't always show up in SERPs. In fact, I looked at a post today, and the meta description showing is not the same, but when I check the source code, it's right. What shows up in Google: http://d.pr/i/jGJg What's actually in the source code: http://d.pr/i/p4s8 Why is this happening? Website is The Tech Block
Intermediate & Advanced SEO | | ttb0 -
How Does SEO Help Local Businesses
Hello, I recently took a position as a digital marketing manger with a advertising agency. Its my job to grow the digital marketing department. One of the issues I am running into is 90% of our clients are local businesses. When doing keyword research it is very difficult to find keywords with lots of search. For example, if I am optimizing for a Ford dealership in Hackensack,NJ there are not a lot of searches for this term. How can I justify a larger SEO budget when there is just not a lot of search volume for these keywords? This is nothing like Dog Training Videos or something similar. Am I missing something? Where can I pull traffic from for local businesses to justify larger SEO budgets? Thanks, Bill
Intermediate & Advanced SEO | | wparlaman0