Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
Using regex to redirect old domain to new while maintaining paths, but not redirecting if specific path in url exists

I am using Kinsta redirect tool to set a simple redirect from one domain to another. This needs to redirect for all paths, except for one specific path (no redirect should occur if it is present in URL). Example:

https://olddomain.com -> https://new.subdomain.com

https://olddomain.com/blog -> https://new.subdomain.com/blog

https://olddomain.com/faq -> https://new.subdomain.com/faq

However if:

https://olddomain.com/my-admin -> https://olddomain.com/my-admin (NO REDIRECT)

I basically need a single regex rule that can do this as I don't have access to a config file.

Closest thing I got was using (.?./technology) to https://new.subdomain.com/$1 as a test; this resulted in only /technology page being redirected to new sites /technology page. I need the opposite behavior

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use the negative look ahead (?!b) syntax in regex which basically means "not matching b".

^(?!\/?my-admin$)\/?(.*)$ to https://new.example.com/$1

  • ^ - starts with
  • \/? - Optional slash prefix
  • (?!\/?my-admin$) - Not "my-admin" with an optional slash prefix
  • (.*) - Any characters in caputuring group that becomes $1
  • $ ends with

Tested here: https://regex101.com/r/jC8nB0/1229

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!