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
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
-
Tool to help find blog / news pages?
Do you guys know of any tools where if I have a list of Url's it can help find blog and news pages and let me know which ones have these.
Intermediate & Advanced SEO | | BobAnderson0 -
Please help with serp placment question?
We own discount banner printing and we are trying to rank 1 for pvc banners or vinyl banners and cannot understand for example how the below is correct, we did suffer a link penalty years ago but we fixed this and the domain has some good links (more and better quality than the sites above us) and cannot understand how we rank below most of the sites above us? If we type on for example pvc banners we get http://www.bannershop.co.uk/cats/pvc_banners.htm https://www.hfe-signs.co.uk/banners.php http://bannerprintingandroid.co.uk/pvc-banners/ http://www.discountbannerprinting.co.uk/banners/vinyl-pvc-banners.html And if we type in vinyl banners we get http://www.vistaprint.co.uk/banners.aspx http://www.bigvaluebanners.co.uk/ http://vinylbannersprinting.co.uk/ http://www.discountdisplays.co.uk/html/vinyl_banners.html https://www.buildasign.co.uk/banners http://www.monkey-print.com/outdoor banners/budget-outdoor-banners http://www.discountbannerprinting.co.uk/banners/vinyl-pvc-banners.html
Intermediate & Advanced SEO | | BobAnderson0 -
[Need advice!] A particular question about a subdomain to subfolder switch
Hello Moz Community! I really was hoping to get your help on a issue that is bothering me for a while now. I know there is a lot of about this topic but I couldn’t find a good answer for my particular question. We are running several web applications that are similar but are also different from each other. Right now, each one has its own subdomain (which was mainly due to technical reasons). Like this: webapp1.rootdomain.com, webapp2.rootdomain.com etc. Our root domain currently points with 301 to webapp1.rootdomain.com. Now, we are thinking about making two changes: changing to a subfolder level like this: rootdomain.com/webapp1 , rootdomain.com/webapp2 etc. Changing our rootdomain to a landing page (lisitng all the apps) and take out the 301 to webapp1 We want to do these changes mainly for SEO reasons. I know that the advantages are not so clear between subdomain/subfolder but we think it could be the right way to go to push the root domain and profit more from juice passing to the different apps. The problem is that we had a bad experience when we first switched from our first wep app (rootdomain.com) to an subdomain (webapp1.rootdomain.com) to set them equal with the other apps. Our traffic dropped a lot and it took us 6 weeks to get back on the same level as before. Maybe it was the 301 not passing all juice or maybe it was the switch to the subdomain. We are not sure. So, I guess my question is do you think it is the right thing to do for web apps to go with subfolders to pass more juice from root to subfolders? Will it bring again huge drops in traffic once we make that change? Is it worth taking that risk or initial drop because it will pay off in the future? Thanks a lot in advance! Your answers would help me a lot.
Intermediate & Advanced SEO | | ummaterial0 -
I am launching a new site, what I need to know about backlinks
Hi 🙂 soon I am launching a new site. It will be focused on topics: Android, smartphones, reviews etc... First I will buy a good looking WP theme, it will be responsive theme. after that when I set up all in theme, after that I will start writing. I will try to write interesting and good content.... This content I will share on my pages: Facebook, Twitter, Google+ and Youtube. So only remains, how to get good backlinks ? good backlinks for Google ? Blog commenting is not good, right ? Writing on relative forums and posting links as source of that information ? Contacting other relative sites for sharing my content ? Am I missed something or not ? In your opinion, which is the best way of getting good backlinks ? And what is the best solution in the beginning, because no one will know my site because my site is new. Thank you 🙂
Intermediate & Advanced SEO | | Ivek990 -
Does having shorter URLs help with rankings?
Hello here.I own an e-commerce website (virtualsheetmusic.com), and some of our most important category pages have pretty long URLs. Here is an example: http://www.virtualsheetmusic.com/downloads/Indici/Violin.html I am evaluating the possibility to shorten URLs like the above to something like: http://www.virtualsheetmusic.com/violin/ But since it is going to pretty hard and time consuming (considering the custom system we have in place on that site), I am trying to find out if it really matters and worth doing it from a SEO stand point. I am aware that from a user prospective shorter URLs are preferable, and we plan to pursue a better URL architecture on our website in the near future just for that, but this question, at the moment, should be strictly related to SEO. Any thoughts on this topic are very welcome!
Intermediate & Advanced SEO | | fablau0 -
Help me solve a keyword ranking mystery please
I posted this and had some help (thank you!) but found some new things, so I thought I'd just start a new thread so no info. is missed. Hi everyone, I'm new here 🙂 So far I've had wonderful success seo wise and none of the updates (Penguin nor Panda) affected any sites, until this one. For example, one site has 7 keywords I'm optimizing for. Out of those 7, all but 2 (and variations of the 2 - one word vs long-tail) completely tanked. These keywords were all on page 2/3. One of the two survivors never budged from page 2 (it's a brand keyword so I was very happy to finally get it to page 2) Now when I check rankings, the other terms show up in the 200-400 spots, but NOT for the URL I was optimizing for (category page) but instead for random products in the category. The only thing I've done differently with the 2 keywords that are still doing well, was focus - we did more link-building for those, but not an extreme amount. Never over-optimize. My question is, how did 2 survive and 5 are still floating up and down. Last night I saw one go up 122 spots, now today down 14. I'm really struggling with this. I just ran another diagnostic crawl here and the report found 0 errors and 0 warnings. I checked category content with a plagiarism checker and found some external duplicate content which I've already taken care of. No critical warnings/messages in WMT either. I'm stumped 😞 Thank you for any help.
Intermediate & Advanced SEO | | Freelancer130 -
Multiple language websites help in pagerank?
My website is in portuguese. If I make a english version and include it at google.com, it will increase my overall page rank?
Intermediate & Advanced SEO | | Naghirniac0 -
Building a Large Local Services Directory - Subdomain Needed?
In 2012 we will be rolling out a directory of local services for our industry. This will ultimately be thousands of additional pages, with city/zip searching, individual provider pages etc. The main reason is for UX -- providing local resources for our industry to compliment the online experience (we're an online B2C retailer) My question is if there are pros/cons to putting this on a subdomain, or if having it on the root is ideal. I don't see a huge influx of backlinks (making a sub fine) but I suppose that could change down the road. I do see some indexing benefits for new terms like 'service x in los angeles' etc, but that would also be fine on a sub. It feels like it would be cleaner to keep separate and on a sub, but maybe we're missing something. We certainty don't want to hurt anything on our primary site which drives the business. Thoughts?
Intermediate & Advanced SEO | | SEOPA0