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

165
Views
Get subdomain in .htaccess

I have the following .htaccess content:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTP_HOST} ^(.*)\.*(.+) 

RewriteRule ^((?s).*)$ index.php?_uri=/$1&_subdomain=%1&_host=%3 [QSA,L]

I want to get subdomain of the url(if it exists), but when I add a quantifier to \., the result of _subdomain is example.localhost instead of example. The full url is example.localhost. Anyone can explain to me?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use ^(.*)\.(.+)

Your current regex is making the . optional, while it should be required exactly once. Since \.* matches 0 or more times, therefore the greedy matching of ^(.*) is capturing everything up to the last character that is matched by (.+)

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!