Redirection Plugin and Regular Expressions
-
I am using Wordpress and the Redirection plugin.
I have recently launched a new site and while it was in development, a lot of broken pages were created and indexed. These are terminating in 404s.
I am looking to redirect all traffic from: /replay/postname/ to the homepage. When I use this regular expression:
Source: /replay/*
Target: /
it removes the /replay/ but leaves the postname.
Any idea how I could redirect all traffic inside of /replay/ to the homepage?
Thanks a bunch, Josh
-
wow, fantastic. Very helpful - really appreciate it!
-
A bit more detail:
/ begins the regular expression - from here on we're replacing what evaluates as TRUE
replay looks for the string "replay" in the URL
\ is an escape character, meaning evaluate what follows as is. We need to escape because / has a specific meaning in regex, but we want it to actually look for a slash
/ follows the escape character, so now its searching for "replay/"
. means any character other than line-break
- means this part is present 0, 1 or many times. You want "anything after replay/" so we repeat the . regex with a ... arriving at (.) The parenthesis tell the * which part its supposed to work on
-
That did it! Thanks!
Do you mind explaining that syntax for me?
-
In regular expressions the / character denotes the end and beginning. Try this instead:
source: /replay/(.)*
target: /
The source can be parsed as "start at replay, escape a / into the string, then any other characters or none at all."
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
-
Barba Plugin and SEO
Hello, community! My client wants to use the barba.js plugin for their new site. What are the implications for SEO?
Technical SEO | | SimpleSearch0 -
Redirecting parent subpage but leaving children as is?
Hi there, I'm working on a website where the webmaster redirected a bunch of parent pages but left the URLs of the children pages as is. For example: domain.com**/business/** got 301 redirected to domain.com**/personal** But they left behind all the children pages of /business/ as is like: domain.com/business/trips domain.com/business/travel instead of changing these to: domain.com/personal/trips domain.com/personal/travel Is there an SEO implication to the children pages_ /business/trips_ and /business/travel having a redirecting parent? Will it affect robots crawling or link equity passing?
Technical SEO | | NikkiHernandez0 -
Avoid landing page redirects
Avoid landing page redirects for the following chain of redirected URLs. http://domainname.com/ https://domainname.com/ https://www.domainname.com/ Anyone know how to solve this issue the correct way?
Technical SEO | | Sammyh0 -
Redirect Chain Issue
I keep running into a redirect chain issue trying to get a non-https/non-www domain to forward directly to the https/www domain on an Apache server. For background, we are forcing https and forcing www, but it appears the non-https/non-www domain is first redirecting to https/non-www and then redirecting again to the desired final https/www version of the domain. (Hope I am making sense here) I am trying to find code to add to my .htaccess file that will perform the following... 301 Redirect
Technical SEO | | FitzSWC
http://example.com directly to https://www.example.com (without 1st redirecting to https://example.com)
http://www.example.com directly to https://www.example.com Any experts in this with any thoughts? Thanks,
Fitz0 -
Redirect Process for Moving a Blog
Hi, I've read several articles about the correct process for moving a blog from a subdomain to the main root domain but am not quite 100% sure as to what to do in our scenario. They were hosting their blog on Hubspot which puts the blog on a sub-domain "blog.rootdomain.com". Realizing it isn't benefiting the main website for SEO they want to move it to the main website. I understand we have to redirect the Hubspot "blog." pages to the new "rootdomain.com/blog" pages but when transferred over (it's a WordPress site) it shows the dates. So, the URL is "rootdomain.com/blog/year/month/title". They want to remove the date. Does that mean the URL must be re-written then redirected so that there's no date showing? There's over 300 posts which will have to be redirected from the Hubspot URLs. Is there a way to avoid setting up the second redirect to remove the dates or make it easier so it isn't one page at a time?
Technical SEO | | Flock.Media0 -
Redirect Error
Hello, I was sent a report from a colleague containing redirect errors: The link to "http://www.xxxx.com/old-page/" has resulted in HTTP redirection to "http://www.xxxx.com/new-page".Search engines can only pass page rankings and other relevant data through a single redirection hop. Using unnecessary redirects can have a negative impact on page ranking. Our site is host on Microsoft Servers (IIS). I'm not sure what is causing these errors. Would it be the way the redirect was implemented.
Technical SEO | | 3mobileIreland0 -
301 redirect relative or absolute path?
Hello everyone, Recently we've changed the URL structure on our website, and of course we had to 301 redirect the old urls to the coresponding new ones. The way the technical guys did this is: "http://www.domain.com/old-url.html" 301 redirect to "/new-url.html"
Technical SEO | | Silviu
meaning as a relative redirect path, not an absolute one like this:
"http://www.domain.com/old-url.html" 301 redirect to "http://www.domain.com/new-url.html" This happened for few thousands urls, and the fact is the organic traffic dropped for those pages after this change. (no other changes were made on these pages and the new urls are as seo friendly as possible, A grade on On-Page Grader). The question is: does the relative redirect negatively affects seo, or it counts the same as an absolute path redirect? Thanks,
S.0 -
Which is the best wordpress sitemap plugin
Does anyone have a recommendation for the best xml sitemap plugin for wordpress sites or do you steer clear of plugins and use a sitemap generator then load it up to the root manually?
Technical SEO | | simoncmason0