I've been directed here by support at WPengine, but I'm not sure whether this question should be asked here or over on Overflow...
I'm using RegEx to redirect all paths and pages of a sub-domain to one page on our new website using a "domain specific" (in this case http://sub1.ourdomain) Redirect 301 ^/.* https://ourdomain/location/city, but there is one single page (eg. http://sub1.ourdomain/email_disclaimer) that I need forwarded to https://ourdomain/legal-notices. It will be the same for about 11 other sub-domains (sub1,.ourdomain sub2.ourdomain etc). How do I do this? Can I create some sort of exception to the wildcard redirect? WPengine suggested a "negative lookahead", which uses ! or something right? But, that'll only exclude it from the wildcard and not forward it elsewhere won't it?
I'm really new to RegEx and am not sure how this works and what syntax to use. I've already looked at Regex negative look-ahead is not working for mod_rewrite between different Apache versions, but am not sure what I'm looking for to help my situation.
To help clarify, the main domain has more than 700 other "ALL DOMAINS" redirects currently in place that are either 1-to-1 (Redirect 301 ^/path/to/page_01/?$ https://ourdomain/newpath/to/new-page-01) or wildcard-to-1 (Redirect 301 ^/path/to/category_01_.* https://ourdomain/newpath/to/category-01-overview)and they are working OK at the moment (when I modify my computer's HOSTS file to emulate a DNS change that hasn't been done on the live website yet). So it is the sub-domain specific wildcard-to-1 redirects I need to create a single page exception for.
Thanks in advance
ournewsite.tldandouroldsite.tldpoint to the same place? Do you have other directives in your .htaccess file?Redirect/RedirectMatchorRewriteRuledirectives in your existing .htaccess file? Is theRedirectdirective you have posted intended to be a working example? (Because it cannot possibly work as intended. TheRedirectdirective does not use regex - it's prefix matching - and if you have just one domain, you're going to get a redirect loop?!).htaccess)? It's just that the syntax you have provided for theRedirect(Apache) directive is not valid and will never match. Do you meanRedirectMatch? (But if you usedRedirectMatchfor the directive you posted in the question then you'll get an infinite loop if you are using just one domain?) But you say that these redirects are "provided in [a] TXT file for WPengine to bulk upload" - so what happens to these directives? Are they parsed in some way?nginx? How is this related? Ordinarily, to "exclude one URL" you just need to make sure that this redirect is before the more general wildcard redirects. More specific redirects first - but presuambly this is how your existing "1-to-1" redirects are already arranged?