简体   繁体   English

子域内的`/`的URL - laravel

[英]URL to `/` within a subdomain - laravel

I use subdomain functionality in Laravel 5.3. 我在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. 我的主应用程序地址格式为http://example.com当在子域名(如http://dev.example.com我使用相同的标题模板。

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 因此,我的页面的头部,其中包含主页的网址,在刀片中定义为{{URL::to('/')}}呈现为http://dev.example.com ,而所需的是http://example.com

to do 去做

is there any good practice to get make Laravel show the main domain URLs? 是否有任何好的做法让Laravel显示主域名? 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. 我发现在vhost / htaccess级别上更容易将用户重定向到所需的域而不是尝试在此代码中工作,让网络服务器在任何代码执行发生之前重定向您。

Hope that helps 希望有所帮助

Thanks, 谢谢,

//P // P

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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