slimphp / Slim-Views

Slim Framework 2 custom views
306 stars 54 forks source link

siteUrl does not work with HTTPS #48

Closed Rudloff closed 8 years ago

Rudloff commented 8 years ago

I am using siteUrl in Smarty templates on an HTTPS website and it generates HTTP URLs. It should generate HTTPS URLs.

silentworks commented 8 years ago

From what I can remember siteUrl generates relative links so it shouldn't make a difference if your server is configured correctly.

Rudloff commented 8 years ago

I'm pretty sure it generates absolute URLs. For example, {siteUrl url='dist/main.css'} gives me http://localhost/alltube/dist/main.css.

silentworks commented 8 years ago

ok just add withUri="false" to the smarty tag and you should get relative urls.

https://github.com/slimphp/Slim-Views/blob/master/SmartyPlugins/function.siteUrl.php#L15

Rudloff commented 8 years ago

I tried {siteUrl url='dist/main.css' withUri=false} but it gives me this URL: http://localhost/dist/main.css

silentworks commented 8 years ago

At this point I am going to suggest not using siteUrl or creating your own without using Slim Request getUrl method. I think the getUrl method is doing absolute urls.

Rudloff commented 8 years ago

It seems my server is not correctly setting $_SERVER['HTTPS'] to true, so Slim getUrl method could not properly detect SSL...