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
-
Urgent help needed for site move with major ranking loss
URGENT HELP/ADVICE NEEDED I am so stressed and worried about my website domain change. I desperately need advice as soon as possible. I will try my best to keep this as brief as possible. I have owned and operated my punk clothing business online at the URL toofastonline.com for 15 years now. And for a long long time we ranked #1 for punk clothing on Google & life was good. However, thanks to the arrival of several cheap marketplaces and other unanticipated changes our ranking dropped considerably. The last few years have been extremely hard on us, to say the least, we came really close to losing the business altogether. But finally after lots of hard work & long hours, things started to improve. Ranking went back up, and we were busy again. I had been toying with the idea of buying the domain TooFast.com for about 10 years, but I never had the money to do it until this now, so I made the leap and as of Jan 9, toofastonline.com became toofast.com. Unfortunately, I now know that I set up the domain change hastily, without doing any of the pre-work Google suggests to do. I didn’t know it then but I did it wrong. And our site which wasranking #7 for punk clothing on Jan. 8th is now number 51 and today is only Jan 24th! I AM PANICKING. I have looked for help, posting jobs on Shopify Experts site several times now, opening accounts with MOZ and SEM Rush, spending countless hours on the phone with GoDaddy, Shopify and even long chats with Google. I have spent all day everyday for the past two weeks trying fix everything to no avail. No one can start on my site issues fast enough. And I have been given so much wrong information that I feel like I have done irreparable damage. I was (am) not qualified to make this kind of a site change alone. Too much was done too fast and without any real working knowledge Google SEO. My brother was the SEO guy and since he left the business I have just been struggling along with it, just trying to keep my head above water. So now for the big question: Should I temporarily change my Shopify stores domain back to toofastonline.com? This way I couldstart at the beginning, fix all the 404 redirects, fix the 301 redirects, clean up code, get the site in top working condition, and then, as Google suggests in theirGoogle Search Console Change of Address Toolstart to do the change of address in small sections, I can not afford to make any more reckless decisions. I have started and stopped, updated, fixed, changed and tried to fix again too many times now. I dont want Google to think I am trying something shady.. I’m not, I just don’t know what I’m doing, and I need help. Here is as much info as I can think of, I am more than willing to pay for help or do the work myself, as long as what I am doing is the right thing. Any and all help/advice/offers are welcome! Maureen CONTACT DETAILS: NAME: Maureen Keough, Owner EM:<a style="-webkit-text-size-adjust: 100%;">Maureen@TooFast.com</a> PH: 856-599-1675 (W) DETAILS OF OUR SET-UP THE APPS & SERVICES WE USE: Google Admin / G-Suite User Gmail for emails Godaddy holds our domains Shopify hosts our storefront. My Shopify store was located at TooFastOnline.com for about 5 years Our Domain Changed From toofastonline.com to toofast.com on Jan 9 In Godaddy both toofastonline.com is being forwarded to toofast.com In Shopify I added toofast.com, made it my primary domain, but left toofastonline.com in there but it is just redirecting to toofast.com. STEPS TAKEN TO CHANGE | ADD | VERIFY THE NEW DOMAIN GoDaddy DNS Records Both Sites - Updated Pointing to Shopify’s IP Address GoDaddy Subdomains For TooFastOnline.com - Redirected But Causing SSL/HTTPS/Privacy errors GoDaddy Subdomains For TooFast.com - Added But Causing SSL/HTTPS/Privacy errors Google Admin - Updated Gmail MX Records TooFast - Added and Updated Gmail MX Records TooFastOnline - Unchanged Google Merchant Center - Updated TooFastOnline is now TooFast Google Merchant Product Feed- Updated TooFastOnline is now TooFast Google Ads - Finally got the New Feed Approved and It is Working Google Search Console - Updated I Think Sitemaps - Added and Asked To Crawl Google Analytics Added TooFast As A Property Seems To Be Working Google Analytics Tag Updated in Shopify Admin Google Search Console - Requested to Move TooFastOnline.com to TooFast.com, still not done. No Redirects were made prior to the “Move” All Social Media Channels Links were Updated By Us Mailerlite MX Records For Bulk Emails - Updated/Verified
Intermediate & Advanced SEO | | TooFast130 -
Open Site Explorer - Spam analysis: need help with inbound links... from my site!
hallo, reading my spam analysis report from open explorer, I found somenthing I don't understand (please see attached image): The long list of links inside the red rectangle are inbound links with a spam score of 5 coming from my same site. How is that possible? Should I remove those links? Also , I see that many of those links are links present in the top navigation bar (about page, home page, service description etc.) or in the sidebar section of the website (categories, recent posts, recent comments). Should I treat them differently? Thank you for your time.
Intermediate & Advanced SEO | | micvitale0 -
Complicated Duplicate Content Question...but it's fun, so please help.
Quick background: I have a page that is absolutely terrible, but it has links and it's a category page so it ranks. I have a landing page which is significantly - a bizillion times - better, but it is omitted in the search results for the most important query we need. I'm considering switching the content of the two pages, but I have no idea what they will do. I'm not sure if it will cause duplicate content issues or what will happen. Here are the two urls: Terrible page that ranks (not well but it's what comes up eventually) https://kemprugegreen.com/personal-injury/ Far better page that keeps getting omitted: https://kemprugegreen.com/location/tampa/tampa-personal-injury-attorney/ Any suggestions (other than just wait on google to stop omitting the page, because that's just not going to happen) would be greatly appreciated. Thanks, Ruben
Intermediate & Advanced SEO | | KempRugeLawGroup0 -
Clean URL help!
Hi all, In short, i'm looking to redirect examplepage.html to examplepage .I've got rid of the .html, sitewide this morning. However I want to redirect Google & people who have bookmarked the old url structure. Currently if you have the extension on or not, it will show in your browser. I'm wanting /examplepage.html to 301 redirect to /examplepage I've gone the normal way I'd do it by adding in .htaccess: Redirect 301 /examplepage.html http://www.example.com/examplepage I'm assuming it isn't redirecting as the example.html page is no longer... what is the way around this? Thanks for any help! In firefox the error of the page is: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
Intermediate & Advanced SEO | | Whittie0 -
Please help on this penalized site!
OK, this is slowly frying my brain and would like some clarification from someone in the know, we have posted multiple reconsideration requests the regular "site violates googles quality guidelines" .."look for unnatural links etc" email back in March 2012, I came aboard the business in August 2012 to overcome bad SEO companies work. So far i have filled several disavow requests by domain and cleared over 90% of our backlink profile which where all directory, multiple forum spam links etc from WMT, OSE and Ahrefs and compiled this to the disavow tool, as well as sending a google docs shared file in our reconsideration request of all the links we have been able to remove and the disavow tool, since most where built in 2009/2010 a lot where impossible to remove. We managed to shift about 12 - 15% of our backlink profile by working very very hard too remove them. The only links that where left where quality links and forum posts created by genuine users and relevant non spam links As well as this we now have a high quality link profile which has also counteracted a lot of the bad "seo" work done by these previous companies, i have explained this fully in our reconsideration request as well as a massive apology on behalf of the work those companies did, and we are STILL getting generic "site violates" messages, so far we have spent in excess of 150 hours to get this penalty removed and so far Google hasn't even batted an eyelid. We have worked SO hard to combat this issue it almost feels almost very personal, if Google read the reconsideration request they would see how much work we have done too remove this issue. If anyone can give any updates or help on anything we have missed i would appreciate it, i feel like we have covered every base!! Chris www.palicomp.co.uk
Intermediate & Advanced SEO | | palicomp0 -
Duplicate Page Content / Titles Help
Hi guys, My SEOmoz crawl diagnostics throw up thousands of Dup Page Content / Title errors which are mostly from the forum attached to my website. In-particular it's the forum user's profiles that are causing the issue, below is a sample of the URLs that are being penalised: http://www.mywebsite.com/subfolder/myforum/pop_profile.asp?mode=display&id=1308 I thought that by adding - http://www.mywebsite.com/subfolder/myforum/pop_profile.asp to my robots.txt file under 'Ignore' would cause the bots to overlook the thousands of profile pages but the latest SEOmoz crawl still picks them up. My question is, how can I get the bots to ignore these profile pages (they don't contain any useful content) and how much will this be affecting my rankings (bearing in mind I have thousands of errors for dup content and dup page titles). Thanks guys Gareth
Intermediate & Advanced SEO | | gaz33420 -
Rankings Nose Diving Help Needed
Hey There SEO Community, I am trying to help these people: http://goo.gl/B1smo They once ranked in the top 10 for "lifewave" and "lifewave patches" but have disappeared. Any idea why and what I can do to help? Thanks!
Intermediate & Advanced SEO | | siteoptimized0 -
Redirect Help - Domain Change and Website Redesign
Hi there, I've redesigned a website for a client, but we are also changing domains and I'm trying to figure out the best way to set up the redirects from their old domain to the new one. 95% of their search engine traffic originally came through brand related keywords that landed on their homepage, and most of the remaining 15% landed on 3 other pages. The new site has pages to replace these 3 main SEO pages, and I'm about to set 301 redirects from their old domain, but I can't figure out the quickest/best way to do it. Is it possible to set up a specific redirect for the 4 main pages (Home + plus the 3 others) then a "catch all" type of thing for the rest of the pages, that redirect either to the homepage, or some sort of "Check out our new Site" landing page. How do you do this, or is there a better way to set it up? Thanks!
Intermediate & Advanced SEO | | timscullin0