Stylesheet not found when link is correct

I am trying to link my stylesheet to my php template for my site. I used the link: <link rel="stylesheet" type="text/css" href="{{app.request.basepath }}/App/views/templates/style.css">

This now works on my localhost server (I am using MAMP), but when I upload files to the web host, I get the error:

Failed to load resource: the server responded with a status of 404 (Not Found)

      

The panel seems to support up to 5.5, where I am using 5.6 on my local server. There might also be a problem.

And it also gives me a link, which is the exact link to the file, without spelling or capitalization. The file I'm trying to link to the stylesheet is in the same folder as the stylesheet. I am also rewriting the .htaccess file because I am using SlimPHP, the file is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

      

I think it might have something to do with not being able to link, but I'm not entirely sure. Thanks in advance for your help.

Edit: I fixed my problem by linking my stylesheet to an open file in my directory. From there I could link any images with CSS, but also I had to put them in a shared directory

+3


source to share


3 answers


This is how I channel themed stylesheets in Slim and Twig. First, I create a new config variable themes.path

that contains the actual path to my theme. Then I set up a route for css/theme.css

:

$app->config([
    'themes.path'    =>  "path/to/themes"
]);

/* Render theme CSS */
$app->get('/css/theme.css', function () use ($app) {
    $app->response->headers->set("Content-Type", "text/css");
    $css_include = $app->config('themes.path') . "/myTheme/css/theme.css";
    $app->response->setBody(file_get_contents($css_include));
}    

      

To use a theme stylesheet in my template documents, I simply do:



<!-- Theme stylesheet -->
<link rel="stylesheet" href="{{site.uri.css}}theme.css" type="text/css" >

      

Where site.uri.css

is a global template variable containing the path to my (public) css directory. You can program this part if you like.

0


source


Better to give us an online address.

But now you have to check the translated url in your html codes.



You have to press Ctrl + U in "Firefox" or right click-> View Page Source.

Then do a search /App/views/templates/style.css">

, then check the full address and change your main code!

0


source


Give 0777 or 0755 permission on the style.css

file to access

0


source







All Articles