Support the ongoing development of Laravel.io →
posted 10 years ago
Forms

Is it possible, with laravel 4, to generate partials urls without the root path ?

I am working for a project that will be hosted on a particular network that handle SSL redirection with a reverse proxy, so any time I request a http... url, the proxy redirects to its https equivalent.

To avoid unneccesary redirects, is it possible to generate (in a form action mainly) a relative url like "/user/login" instead of a full url "http://mysite.com/user/login" ?

Actually, my problem is the following:

  • user hits /user/login form (http => https from proxy)
  • user submit form, but laravel form generator stored the full url with http:// in the form
  • firefox warn the user that content will be submitted through unencrypted network
Last updated 3 years ago.
0

I've ended up getting an answer on stackOverflow, heere's the solution:

From the code source, route method generate an absolute URL by default, you may set it to false:

<a href="{{ URL::route('dashboard-get',array(),false) }}">Dashboard</a>
Update

You can also define your own custom links by

HTML::macro('Rlinks',function($routeName,$parameters = array(),$name){ 
    return "<a href=".substr(URL::route($routeName,$parameters,false), 1) .">"
       .$name.
    "</a>";
});

Then call your macro

{{ HTML::Rlinks('dashboard-get',array(),'Dashboard') }}
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

kitensei kitensei Joined 29 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.