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?
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]
You can use this rule to handle this rewrite:
RewriteCond %{HTTP_HOST} ^api\. [NC]
RewriteRule ^app/ /assets/api/app/index.php [L,NC,QSA]