Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda