apache - .Htaccess RewriteRule (Subdomain vs Request_URI) -


i have several domain names, each own multiple subdomains. currently, have global rewriterule domain specific request_uri meant rest apis.

.htaccess

rewriteengine on  rewriterule ^/?api/(.*)$ /api/inbound.php [nc,l]  

affected url examples:

acct.domain1.com/api/clients/123

my.domain2.com/api/tasks/2323

new.domain3.com/api/products/1212

and rule works great!

now i've started using these subdomains:

api.domain1.com/api/clients/123

api.domain2.com/api/tasks/2323

api.domain3.com/api/products/1212

though still works, it's annoyingly redundant. so, if subdomain happens "api, sandbox, api.test, or chosen nuance i'm going omit /api/ path url.

how rewriterule scenario?

examine http host header value rewritecond:

rewriteengine on rewritecond %{http_host} ^api(\.test)?|sandbox rewriterule ^/?(.*)$ /api/inbound.php [nc,l] 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -