mercredi 13 mars 2019

Subdomain for api routes Laravel 5.7

please I try to make a subdomain for my RESTFUL API to separate API from Web App.

So first I create to subdomain from in my hosting provider dashboard, and after I add a virtual host:

<VirtualHost *:80>
    ServerName api.mydomain.com
    ServerAlias www.api.mydomain.com

    ServerAdmin webmaster@localhost
    DocumentRoot /projectpath/public

    ErrorLog ${APACHE_LOG_DIR}/error_project.log
    CustomLog ${APACHE_LOG_DIR}/access_project.log combined

    <Directory "/projectpath/public">
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    <IfModule mod_rewrite.c>
        RewriteCond %{HTTPS} !=on
        RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
        RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
    </IfModule>

</VirtualHost>

And finally, I add the domain group in my api.php file

Route::group(['domain' => 'api.mydomain.com'], function(){
.....
});

Any help, please. Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire