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

161
Views
How to rewrite a subdomain with sufix at apache's .htaccess

I've created an alias for subdomain "api" on my server using this following code on .htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteCond %{HTTP_HOST} ^api\. [NC]
RewriteRule ^app/ /assets/api/app/index.php [L,NC,QSA]

And it's working fine through this following url:

https://api.mysite.com/assets/api/app

But I need want to add a suffix /app/ in the address to rewrite api.mysite.com/app/ to /assets/api/app/index.php

After that I will user others suffixes to rewrite for example:

Example 01 (suffix app):

Origin: api.mysite.com/app/carts

Destination: /assets/api/images/index.php

to receive only carts

Example 02 (suffix images):

Origin: api.mysite.com/images/banner/21

Destination: /assets/api/images/index.php

to receive only banner/21

Example 03 (suffix lib):

Origin: api.mysite.com/lib/lib.js

Destination: /assets/api/libs/index.php

to receive only carrousel/21

All the context will be used in my restful api.

api.mysite.com/app/carts

My Api restfull is getting the path app/carts but I want to pass only /carts to index.php

Server's root is:

/home/storage/c/bc/69/mysite

I want that the server ignores those following suffixes: app, images e lib. Someone know how to do it?

Error routing

Ps.: I've my .htaccess working as a charm while accessed directly by www.mysite.com/asssets/api/app/carts and this is the code for .htaccess stored in /home/storage/c/bc/69/mysite/assets/api:

RewriteRule ^(^app/){1} /assets/api/app/index.php [NC,QSA]

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use this rule to handle this rewrite:

RewriteCond %{HTTP_HOST} ^api\. [NC]
RewriteRule ^app/ /assets/api/app/index.php [L,NC,QSA]
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!