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
-
Please... Help me convince my boss that Keyword Density is not-important / damaging.
If you can, please provide any and all talking points that I can use in this argument. It seems that no matter what I show him, including Matt Cutts' video debunking Keyword Density back in 2011, it doesn't seem to stick. He is fully, 100% convinced that keyword density is hugely important and we need to focus our time and energy on it. Any sources you might have to help me show him that this is a myth would be hugely appreciated. Thank you.
Intermediate & Advanced SEO | | TaylorRHawkins2 -
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 -
.htaccess 301 Redirect Help! Specific Redirects and Blanket Rule
Hi there, I have the following domains: OLD DOMAIN: domain1.co.uk NEW DOMAIN: domain2.co.uk I need to create a .htaccess file that 301 redirects specific, individual pages on domain1.co.uk to domain2.co.uk I've searched for hours to try and find a solution, but I can't find anything that will do what I need. The pages on domain1.co.uk are all kinds of filenames and extensions, but they will be redirected to a Wordpress website that has a clean folder structure. Some example URL's to be redirected from the old website: http://www.domain1.co.uk/charitypage.php?charity=357 http://www.domain1.co.uk/adopt.php http://www.domain1.co.uk/register/?type=2 These will need to be redirected to the following URL types on the new domain: http://www.domain2.co.uk/charities/ http://www.domain2.co.uk/adopt/ http://www.domain2.co.uk/register/ I would also like a blanket/catch-all redirect from anything else on www.domain1.co.uk to the homepage of www.domain2.co.uk if there isn't a specific individual redirect in place. I'm literally tearing my hair out with this, so any help would be greatly appreciated! Thanks
Intermediate & Advanced SEO | | Townpages0 -
Google Recon Request 4 Failed - This is crazy. HELP!
We run a niche website selling sunglasses at www.aluminumeyewear.com. I've been trying to resolve a 'Failed Quality Guidelines' message since May. My 4th recon request has just failed and I've exhausted all changes that I believe I need to make. I rely on this site to pay my bills etc so obviously I really need to get this resolved. I would be grateful if someone from Google could actually point out whats wrong instead of an unhelpful auto response.Steps taken.1. Rewrote content as it was a bit thin. Recon failed.2. Removed old products that couldn't be reached from every page. Recon failed.3. Submitted back link audit and added 'sitemap' link to footer. Recon Failed.4. Removed 40+ old urls that existed from old Yahoo! store (didn't realize they still existed). Recon failed.I felt sure #4 would resolve the issue so feeling pretty low right now that it didn't. That being said doing a site:aluminumeyewear.com it looks like I missed one of them which was http://www.aluminumeyewear.com/demora/black/, however it just returns a 404 which would seem harsh to penalize me for.The only other pages that I can think of are some dynamic pages that the store uses to create reviews such as:www.aluminumeyewear.com/product-reviews-add.aspx?product=2www.aluminumeyewear.com/resize.aspxI'm pretty sure that the reviews page is blocked via robots txt. The resize.aspx is a blank page with javascript as its needed by the PowerReviews Express system to work, and many many merchants use that platform so it would be hard to think its that.Thanks in advance.
Intermediate & Advanced SEO | | smckenzie750 -
Social Signals...I Need More
Hi, Having used the Open Site Explorer (page specific metrics) tool I've realized I'm lacking in the Social Signals area...I have only 1 tweet and ZERO for everything else (Facebook shares, Likes, Google +1 etc). So I have 2 quesitons: How can I get more social signals (is there a service I can use to do it)? How long will the new social signals take to appear in the Open Site Explorer information? I've just paid someone on Fiverr.com to share my website link on his Facebook account, to tweet it, and also to use PingFM... Any other ideas would be GREAT - I can see this is a real weakness for my websites... Thanks, James
Intermediate & Advanced SEO | | James10 -
Is there an search marketing / keyword tool in existence that can solve my need?
I'm looking for a tool that can do the following:
Intermediate & Advanced SEO | | PTC4SEO
Organize a keyword universe and its data/metrics:
-track keyword data over time (search volumes/trends, relative competition metrics, rankings,
etc)
-Sort keywords into buckets/silos/ad groups
-allow you to assign individual keywords to multiple silos/groups and show the relationships between groups based on keyword relationships.
-incorporate a site map
-tie keyword targets to static pages, informational content (SEO) & landing pages (PPC)
-help with KW and/or competitive research (optional)
-tie into web analytics / marketing on-demand software (optional) I know that this is a lot of functionality, but for enterprise search marketing, this could be a game changer for my strategy (if it exists currently) or for the industry (if it doesn't exist). Please share you solution suggestions here...0 -
Need to migrate multiple URLs and trying to save link juice
I have an interesting problem SEOmozers and wanted to see if I could get some good ideas as to what I should to for the greatest benefit. I have an ecommerce website that sells tire sensors. We just converted the old site to a new platform and payment processor, so the site has changed completely from the original, just offering virtually the same products as before. You can find it at www.tire-sensors.com We're ranked #1 for the keyword "tire sensors" in Google. We sell sensors for ford, honda, toyota, etc -- and tire-sensors.com has all of those listed. Before I came along, the company I'm working for also had individual "mini ecommerce" sites created with only 1 brand of sensors and the URL to match that maker. Example : www.fordtiresensors.com is our site, only sells the Ford parts from our main site, and ranks #1 in Google for "ford tire sensors" I don't have analytics on these old sites but Google Keyword Tool is saying "ford tire sensors" gets 880 local searches a month, and other brand-specific tire sensors are receiving traffic as well. We have many other sites that are doing the same thing. www.suzukitiresensors.com (ranked #2 for "suzuki tire sensors") Only sells our Suzuki collection from the main site's inventory etc We need to get rid of the old sites because we want to shut down the payment gateway and various other things those sites are using, and move to one consolidated system (aka www.tire-sensors.com) Would simply making each maker-specific URL (ie. fordtiresensors.com) 301 redirect to our main site (www.tire-sensors.com) give us to most benefit, rankings, traffic etc? Or would that be detrimental to what we're trying to do -- capturing the tire sensors market for all car manufacturers? Suggestions? Thanks a lot in advance! Jordan
Intermediate & Advanced SEO | | JordanGodbey0 -
Do i need different IP addresses for mini sites?
Hi everyone We are currently building some non-advertorial based mini sites the link to a main "money site", these mini sites are all run off wordpress or similar and have different designs, however all the WHOIS data remains under one company. So therefore I dont know if really you need different Class C IP's anymore as google et al will just look at the whois records and link the websites up that way? Is this tactic still worth doing? Thanks for any input!
Intermediate & Advanced SEO | | SEOwins0