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

After reading Dayle Reese's chapter on URL generation (http://daylerees.com/codebright/url-generation) I'm stuck with a question.

Let's say I wrote a cool application up and running and the whole world is happy. I'm using URL::to() a lot to guide everybody to their right place. Now I install an SSL certificate.

Who should I find and replace every URL::to(); with URL::secure() instead of just changing the 'url'-config in App > Config > App.

As far as I know the exact same thing will happen, or am I missing something crucial?

Sven

Last updated 3 years ago.
0

why don't you look at the secure() & to() functions and see if there is any significant things being done or secure is just adding an s to http://..

0

It doesn't; secure() even calls to(). But why going through the trouble? It looks all pretty clear and maybe it's just because Laravel doesn't want to force you to work in a certain way.

I guess I'm overthinking stuff lol

0

There is always the forceShema() function on the URL generator to force http or https to be generated throughout your site. https://github.com/laravel/framework/blob/4.2/src/Illuminate/Routing/UrlGenerator.php#L204

The URL in app.php config file is only used by Artisan to generate URL for the application, its completely ignored when your application is accessed from the web.

Personally I generate URLs either by controller actions URL::action() or named routes URL::route(), that way when I want/need to change the URL structure of a route I don't need to go through my application change change all the URL::to() etc. They're generated dynamically and only set in one place which makes them easily maintainable.

Last updated 10 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

sven22 sven22 Joined 8 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.