Reputation: 349
I am using Laravel 5.7. Currently have all the route go through Api.php
, web.php
, and website.php
. In live version of the app, there is a subdomain pointing to website.php
is [anything].websiteaddress.com
, and domain www.websiteaddress.com
is pointing web.php
. In local environment, how can I access subdomain using localhost:8000
. I have tried to use [anything].websiteaddress.com
, it does not work. What is proper way to access subdomain?
Upvotes: 1
Views: 2108
Reputation: 9171
You can use http://lvh.me:8000.
lvh.me is a free service that resolves itself with all subdomains to localhost
.
There’s nothing to install or run. If you want to test the example
subdomain all you have to do is go to http://example.lvh.me:8000 and it would work.
It even works without subdomains too. For example, if you have an app running at localhost:8000 on your dev box, you could go to lvh.me:8000 to load it.
You can try also http://vcap.me:8000 and http://localtest.me:8000 they all resolve to 127.0.0.1
or localhost
.
Upvotes: 2
Reputation: 10997
1.Configure in Web server httpd.conf create virual Host ip or name what you want
<VirtualHost *:80>
ServerName website.com
ServerAlias *.website.com
</VirtualHost>
2.route configuration like
Route::group(array('domain' => '{account}.website.com'), function() {
Route::get('/', function($account, $id) {
// ...
return Redirect::to('https://www.website.com'.'/'.$account);
});
});
Upvotes: 2