Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda