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

125
Views
Apache RewriteRule allow blank after slash or specified values

I need help with the following Apache RewriteRule

RewriteRule ^(customers)/(active|create)/?$ /mod/customers/?type=$2 [NC,L]

This rule works only if there's something after the / Eg: http://example.com/customers/active

It won't work if the url is http://example.com/customers

How can this RewriteRule be written so http://example.com/customers will work, as well as http://example.com/customers/active

/customers followed by nothing, or /customers followed by /active or /create

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use this regex:

^(customers)(?:/(active|create))?/?$

It uses an optional non-capturing group to allow for a URL such as http://example.com/customers as well as http://example.com/customers/active. The `active|create is still captured in group 2.

Demo on regex101

This regex allows for a trailing / on the URL e.g. http://example.com/customers/ or http://example.com/customers/active/. If that is not desired, just remove the /? in front of the $ i.e.

^(customers)(?:/(active|create))?$

Demo on regex101

over 4 years ago · Santiago Trujillo 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!