Apache2: CSS not loading when the file is in another folder - html

The problem is that my CSS is not loading.
I have a folder /var/www/example, and in it i have my index.php
and another folder assets where i have the folder /css
in my index.php i linked the css like this :
<link type="text/css" href="/assets/css/style.css" rel="stylesheet">
But when i put style.css in /var/www/example with index.php and i change my code to
href="style.css it works !!
im working with Apache2

The root directory is example so you have to put /example before assets the link should be like the example below, Another idea is to remove the / before assets as it is not the root directory (i.e it is directory) of the index.php file.
<link type="text/css" href="/example/assets/css/style.css" rel="stylesheet">

Related

Problems with favicon, can not make it to show up whenever the path is different than having it saved in the same folder as the html one

<link rel="icon" type="image/x-icon" href="/photos/icon.ico" /> so this does not work
<link rel="icon" type="image/x-icon" href="icon.ico"> but this works having the favicon in the same folder as the html one.
How do I make it so that it will show up having it saved in the photos folder?
its a path problem. you can try one of two things.
if on a live server already, you can direct it to where the file is located as this href="https://www.example.com/photos/icon.ico" (remember to path correctly if your photos folder isnt located in public_html)
if the resource is located on a local server you can try using "./" (same folder as current page) or "../"(previous folder from current page).
<link rel="icon" type="image/x-icon" href="photos/icon.ico"/>
Removing the first "/" may solve this problem. If it doesn't that is because of the images folder location. The images folder location should be inside the same folder as the html folder. HTML_folder/photos/icon.ico is what it technically is saying, but it should look like photos/icon.ico .

Github pages not loading css on subfolders

Any idea why github pages stoped loading css and images in subfolders, it works fine on the root of the site.
When i checked the source code of the page, i see this
"href="css/bootstrap-3.3.6/css/bootstrap.min.css">"
instead of
"href="/css/bootstrap-3.3.6/css/bootstrap.min.css">".
In my config file I have a line
baseurl : /
--> crowd42.github.io
Thanks
It should work the way it is baseurl : "/" if when loading assets you use that variable:
<link rel="stylesheet" href="{{site.baseurl}}css/main.css">
As it seems that you aren't using base urls, you can try forcing the root path with a slash at the beginning:
<link rel="stylesheet" href="/css/main.css">
Or including the absolute path:
<link rel="stylesheet" href="{{'css/main.css'|absolute_url}}">
with baseurl: "".

Linking my favicon.ico file, but something goes wrong

I uploaded my favicon.ico to /images/favicon.ico directory and I'm using this code to link it, but it doesn't show up on my website.
What am I doing wrong?
<link rel="shortcut icon" href="/images/favicon.ico" />
Technically speaking, favicon files should be in the root directory rather than a sub-directory, and if there's a favicon.ico file in the root directory technically you don't need to declare the path at all.
If you don't call the favicon favicon.ico, you can use that tag to specify the actual path (in case you have it in an images/ directory). The browser/webpage looks for favicon.ico in the root directory by default.
If you really want to keep it in a sub-directory, do this:
<link rel="icon" href="/images/favicon.ico" type="image/x-icon">

Linking my stylesheet without the root so can use the folder anywhere

I linked my stylesheet customstyle.css to my index.html but when i copy the folder to another drive the stylesheet wont get linked how do i overcome this problem as i have to send the folder to another person
<link rel="stylesheet" type="text/css" href="D:\healthplus\style.css">
Make sure that index.html and customstyle.css are in the same folder. Then in index.html you should link to your stylesheet like this:
<link rel="stylesheet" type="text/css" href="customstyle.css">
This is a relative path because it doesn't start with a /

Why AppEngine doesnt load my stylesheet?

I import my stylesheet with this line on the html
<link href="styles.css" rel="stylesheet" type="text/css" />
it works fine when I drag-n-drop the file into the browser but when I load trough AppEngine it doesnt take the css file or the pictures that are located in a child file
Can you show your app.yaml and your folder structure? Is that Python, Java, PHP, Go?
If its python, you should use a folder for your static files, add a handler for this folder in your app.yaml file:
handlers:
- url: /static
static_dir: static
And then link it as:
<link href="/static/styles.css" rel="stylesheet" type="text/css" />
For more info take a look at https://developers.google.com/appengine/docs/python/gettingstartedpython27/staticfiles