Forum

Thread tagged as: Question, Runway

Linked CSS not loading in folder

In my template I have (among others): <link href="/css/bootstrap-grid.css" rel="stylesheet">

Works great on www.mydomain.com/mypage

But when I have www.mydomain.com/mypage/mysubpage

It doesn't link correctly. It appears it's trying to grab the css file from www.mydomain.com/mypage/css instead of the normal root.

I'm sure it's something really simple. It's just eluding me at the moment.

Perch Runway: 3.0.14, PHP: 7.0.27, MySQL: 5.6.36, with PDO

Raymond Wiggins

Raymond Wiggins 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you sure this is what you have?

<link href="/css/bootstrap-grid.css" rel="stylesheet">

All your links to CSS files should start with a /

Yes, I have the forward slash in the link as shown.

<link href="/css/bootstrap-reboot.css" rel="stylesheet">

Is exactly how it is shown in /perch/templates/pages/default.php

When viewing the source code in the browser, it also shows up exactly like that.

For what it's worth, here's my .htaccess contents.

# Perch Runway
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/perch
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /perch/core/runway/start.php [L]
Drew McLellan

Drew McLellan 2638 points
Perch Support

What errors do you get in the browser console?

Ah, that was the clue I needed. Browser console indicated that the images weren't found. So I added the "/" before the at the beginning of the src for the image and all is good.

thanks for your help.