Haring10 Haring10 - 4 years ago 90
PHP Question

Link From Subdomain to Root Domain Laravel 4.2

I have 1 subdomain in my app:

and then the root is
. While in
I want to send an email to a user to log in to
but right now it is sending the link to

How can I use the
{{ URL::to('login', array($code)) }}
method to route to the main domain and not the sub domain?

I do not want to use .htaccess

Answer Source

You could use named routes. For example, in your routes.php:

Route::get('login/{param}', array('as' => 'TestLogin', 'uses' => 'HomeController@login'));

Then, in your Blade template:

{{ URL::route('TestLogin', array('param' => $code)) }}

I don't know what your routes file looks like, so you would need to adjust this to fit your needs. The important piece is the 'as' => 'TestLogin' since that's what names the route and allows it to be referred to as such throughout your application.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download