0

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

9
  • Do ournewsite.tld and ouroldsite.tld point to the same place? Do you have other directives in your .htaccess file? Commented Jul 14, 2016 at 1:46
  • actually, the domain is the same. there is hundreds of other 1-to-1 redirects and quite a few wildcard-to-1 redirects. The website has been completely rebuilt with a new path structure and canonical URL scheme. We just haven't pointed the A and CNAME records away from the existing server to the new server yet Commented Jul 14, 2016 at 1:47
  • "actually, the domain is the same" - that's rather an important point, since you now have to be careful of redirect loops (why did you use two different domains in your question?). Are you currently using Redirect/RedirectMatch or RewriteRule directives in your existing .htaccess file? Is the Redirect directive you have posted intended to be a working example? (Because it cannot possibly work as intended. The Redirect directive does not use regex - it's prefix matching - and if you have just one domain, you're going to get a redirect loop?!) Commented Jul 14, 2016 at 2:08
  • 1
    I'm not sure that I follow... Are these directives in an Apache config file (ie. .htaccess)? It's just that the syntax you have provided for the Redirect (Apache) directive is not valid and will never match. Do you mean RedirectMatch? (But if you used RedirectMatch for 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? Commented Jul 14, 2016 at 9:01
  • 1
    You've also tagged your question 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? Commented Jul 14, 2016 at 9:04

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.