简体   繁体   中英

URL to `/` within a subdomain - laravel

I use subdomain functionality in Laravel 5.3. My main app address has format http://example.com When within a subdomain such as http://dev.example.com I use same templates for header.

problem

as a result, the head of my page, which contains url to homepage, defined in blade as {{URL::to('/')}} renders as http://dev.example.com , while desired is http://example.com

to do

is there any good practice to get make Laravel show the main domain URLs? I could add a variable in controller used for subdomain purposes, but it seems not really professional way to solve the issue.

I find this easier to do on the vhost/htaccess level to redirect the user to the required domain instead of trying to work in the code for this, have the webserver redirect you before any code execution happens.

Hope that helps

Thanks,

//P

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM