Regular Expression / Wildcard Redirect Situation
-
I am dealing with an interesting situation. Here's what's going on:
Current URLs Example1:
www.domain.com/red-widgets-cid-1234.html
www.domain.com/red-widgets-cid-1234-1.html
www.domain.com/red-widgets-cid-1234-1-1.htmlCanonical on All Above URLs:
www.domain.com/red-widgets-cid-1234.htmlNew URL:
www.domain.com/red-widgets-cid-4567.html
Current URLs Example2:
www.domain.com/red-widgets-cid-1234+10.html
www.domain.com/red-widgets-cid-1234+10-1.html
www.domain.com/red-widgets-cid-1234+10-1-1.htmlCanonical on All Above URLs:
www.domain.com/red-widgets-cid-1234+10.htmlNew URL:
www.domain.com/red-widgets-cid-6789.htmlI want to make sure all variations of the above URL redirect to the new url. What wildcard 301 redirect / regular expression can I use to tackle these ?
-
Hi Nakul,
Forgive me if this is too simplistic...
The following rewrite rules should cover the examples you provided:
RedirectMatch 301 red-widgets-cid-1234.html http://www.domain.com/red-widgets-cid-4567.html
RedirectMatch 301 red-widgets-cid-1234- http://www.domain.com/red-widgets-cid-4567.html
RedirectMatch 301 red-widgets-cid-1234+ http://www.domain.com/red-widgets-cid-6789.htmlWe just need to escape the special characters (period, hyphen and plus sign).
This should cover the examples you provided, and no need for any elaborate RegEx patterns. Of course, if there are variants your example doesn't mention, things could get more complicated. (I'm also assuming here you're on an Apache environment.)
If I've misunderstood your question or the situation is more complicated than your example demonstrates, let me know.
Thanks,
Mike
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
-
I've got duplicate pages. For example, blog/page/2 is the same as author/admin/page/2\. Is this something I should just ignore, or should I create the author/admin/page2 and then 301 redirect?
I'm going through the crawl report and it says I've got duplicate pages. For example, blog/page/2 is the same as author/admin/page/2/ Now, the author/admin/page/2 I can't even find in WordPress, but it is the same thing as blog/page/2 nonetheless. Is this something I should just ignore, or should I create the author/admin/page2 and then 301 redirect it to blog/page/2?
Intermediate & Advanced SEO | | shift-inc0 -
301 redirects cross domains
Hi Moz Community. We have a client that has Website A and Website B. Website A is going to be replaced by Website C, a new website and brand. Some products sold on Website A are going to be split out to Website B & C. i.e. Say Website A sells eight products - then four will go to Website B and four to Website C. OUR QUESTION Technically we know we can 301 redirect the Website A products to the relevant Website B & Website C products. 1. Given this convoluted structure, will there be any negative ramifications for SEO? and; 2. Which website would you redirect the homepage to, B or C?
Intermediate & Advanced SEO | | WCR0 -
301 Redirect / Canonical loop on home page?
Hi there, My client just launched a new site and the CMS requires that the home page goes to a subfolder - clientsite.com/store. Currently there is a redirect in place such that clientsite.com -> clientsite.com/store. However, I want clientsite.com to be the canonical version of the URL. What should I do in this case, given that there is now a loop between the redirected page and the canonical page?
Intermediate & Advanced SEO | | FPD_NYC0 -
Ending URLs in .html versus /
Hi there! Currently all the URLs on my website, even the home page, end it .html, such as http://www,consumerbase.com/index.html Is this bad?
Intermediate & Advanced SEO | | Travis-W
Is there any benefit to this? Should I remove it and just have them end with a forward slash?
If I 301 redirect the old .html URLs to the forward slash URLs, will I lose PA? Thanks!0 -
Create a link or redirect?
We have 60 demo movie pages on our site. We no longer link to these movie pages internally, because they are outdated; however, a lot of our partner companies are still linking to these pages. Some of these pages will have 10-15 linking root domains and a page authority of 30+... so pretty decent authority. These pages only include a movie on the pages, no links. I am trying to pass some of the link juice from these pages to other pages on our site. I am wondering if I should: A)Include transcripts on these pages, then link back to our current product page or solution pages? B)Set up redirects from these pages to a product or solution page? C)Set up a redirect to our homepage? Any advice? Thanks, Mike
Intermediate & Advanced SEO | | Mike.Goracke0 -
If I hired you/your company to do my SEO ...
If i hired you or your company to do SEO for my site (http://goo.gl/XUH3f) what would be the first steps you'd take? I'm pretty sure i've covered all of the basics myself, I'm just left trying to figure out what i should do next... rankings have been going up and down for the last few weeks, but even when they're up, they're not high enough 🙂 (and then they go back down anyway) ... I know some of you are going to say build links, please at least give me an example of one or two sites you'd try to get to link to mine... I'm open to any advice or feedback as I'm just a website owner who's been doing their own SEO & learning on the fly... Thanks a lot!
Intermediate & Advanced SEO | | Prime850 -
Questions about 301 Redirects
I have about 10 - 15 URLs that are redirecting to http://www.domainname.comwww.domainname.com/. (which is an invalid URL)The website is on a Joomla platform. Does anyone know how I can fix this? I can't figure out where the problem is coming from.
Intermediate & Advanced SEO | | JohnParker27920 -
Bing/Yahoo! Updates
On March 27th I noticed a huge rankings drop across the board on a client site in Bing and Yahoo! After some research, I found this article on SEOroundtable (it also links back to a Webmaster World discussion). For this particular site we're talking a few dozen of keywords dropping off the first page, or even from the first page dropping out of the top 50. The only thing not affected were brand keywords. The site was recently relaunched, and has a fairly weak backlink profile right now. It doesn't use keywords in the domain (which was one of the things identified in the SEOroundtable article). Has anyone else noticed changes? If so, what do you attribute them to and how are you combating them?
Intermediate & Advanced SEO | | BedeFahey0