Search code examples
phplaravellaravel-4subdomain

Link From Subdomain to Root Domain Laravel 4.2


I have 1 subdomain in my app: admin.test.com and then the root is test.com. While in admin.test.com I want to send an email to a user to log in to test.com/login/aseqgaasd but right now it is sending the link to admin.test.com/login/aseqgaasd.

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


Solution

  • 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.