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

426
Views
PHP/Apache - Web server not respecting RewriteRule?

I have a site hosted on Hostinger and was experimenting with RewriteRule in .htaccess, and here's what I ended up using:

RewriteEngine on
RewriteRule ^/(accounts)/[0-9]+[/]?$ /account?$2

I was hoping that this would redirect /accounts/[id] to /account?[id] but instead I get a 404. Any thoughts?

EDIT: I also did not mention that this is on a subdomain. Should htaccess be on the www document root and not the subdomain document root? Would be weird

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are only capturing only one group, and pasting $2, therefore this wont work... instead you should do:

RewriteRule ^(accounts)/([0-9]+)[/]?$ /account?$2 [R=301,L]
                         ^      ^

But you can just capture one group:

RewriteRule ^accounts/([0-9]+)/?$ /account?id=$1 [R=301,L]
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!