regex - Mod_rewrite cross domain extensions -
have multiple domain extensions , have therefore written mod_rewrite takes rewrites url .com setting original extension query parameter:
rewritecond %{http_host} ^api\.example\.(co\.)?(.*)$ rewritecond %{http_host} !^api\.example\.com$ rewriterule ^(.*)$ http://api.example.com/$1?l=%2 [qsa,r]
this works fine, problem need internal redirect api.example.com/index.php
instance:
api.example.fr/v1/users =>
(ext) api.example.com/v1/users/?l=fr
(int) api.example.com/index.php
i've been messing time , appreciate on matter...
many regards
assuming document_root
api.example.fr
, api.example.com
same.
you can have code this:
rewritecond %{http_host} ^api\.example\.(co\.)?(.*)$ rewritecond %{http_host} !^api\.example\.com$ rewriterule ^(.*)$ http://api.example.com/$1?l=%2 [qsa,r,l] # add missing /v1/ if needed rewritecond $1 !=index.php rewriterule ^((?!v1/).*)$ /v1/$1 [r,l,nc] rewritecond %{http_host} ^api\.example\.com$ rewriterule ^(?!index\.php) /index.php [l,nc]
Comments
Post a Comment