I'm trying to style the custom error pages in IIS7 with a linked CSS style sheet.
This works.
<html><head><title>404 - File or directory not found.</title>
<LINK href="http://stage.mysite.com/custErr/css/style.css" rel="stylesheet" type="text/css">
</head><body>Page Not Found</body></html>
I've created a virtual directory in mysite called custErr that contains the css and images needed.
But to make it easier to deploy I'd like to have it relative like this...
<html><head><title>404 - File or directory not found.</title>
<LINK href="../css/style.css" rel="stylesheet" type="text/css">
</head><body>Page Not Found</body></html>
After trying this I find that relative paths don't seem to work. In fact a style sheet in the c:\inetpub\custerr\en-US folder doesn't work either.
Where are these pages being served from?
Is there an easier way of doing this?
So I don't have to modify each and every absolute path for each environment?
I know this is a late reply but the reason why the relative paths don't work (I think) is because if you hosted a site such as www.myfavouritephotos.com and on visiting a directory on that site such as www.myfavouritephotos.com/images/ which is a directory in your website that doesn't have a default document like Default.aspx or whatever your site is set up as serving as a default page, IIS would return a HTTP Response of 404 for not finding a page to serve up or a 403 response because the user may not have the necessary rights to view the content of the directory under that url.
IIS by default would serve either the 404.htm or 403.htm file from within the c:\inetpub\custerr\en-US directory by default but when you replaced it with a custom htm file that replaces 404.htm, the relative path to the stylesheet you reference from that htm file would make a request at what the original url made to the server was so www.myfavouritephotos.com/images/(../css/style.css) which would result in an incorrect relative path so it may be able to be avoided by using a reference to a stylesheet with www.myfavouritephotos.com/css/style.css
Related
For some reason, I can only access my CSS files in my Node.js app if they are located in the same folder or deeper than HTML.
Folder structure that works:
I can assess CSS here using the css/style.css path as it is located in the sub-folder of the HTML folder. It also works for the nested sub-folders.
Folder structure that doesn't work:
But when I try to move CSS on the level higher, it can't be accesses using ../css/style.css, an error message about the incorrect MIME type (text/html) appears and the style doesn't apply.
Am I missing something or this is intended?
The issue might be with path, it must be
<link rel="stylesheet" type="text/css" href="../css/style.css">
When I use the command hugo, it generates the index.html in the Public folder. When I open index.html, the site load like this:
But when I use the hugo serve command locally, it generates the link http://localhost:1313/, and the site load properly. It loads like this:
I think the problem is because of the not proper rendering of files or anything similar.
My approach:
I added the code relativeURLs = true and uglyURLs = true at top of the config.toml file but still it does not rendered properly.
I had set baseurl = "/" in config.toml file but this also does not work.
Your theme might be loading CSS using {{ .Site.Baseurl }}.
For example:
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/style.css">
In that case, make sure that the BaseUrl defined at the top of your config.toml file is set to http://localhost:1313, which will allow your local server to find the CSS file.
You're CSS file is not loading properly. This can have several reasons, for example:
http url on an https website.
wrong "integrity" hashes on you css file.
css file is not deployed or not on same location on the server.
Google developer tools plugin might help here. If you right click on your web page, click "inspect" and go to console. You can see any loading errors.
You can install Web Server for Chrome and choose the /public folder of your Hugo website. Your site should now render correctly at the url configured (http://127.0.0.1:8887 in the example screenshot).
You might want to set baseURL to the absolute path of the public folder.
Fixed this by configuring baseUrl in config.toml.
If you're deploying using GitHub pages, you'll want to make your baseUrl equal to your github pages domain.
I have an index file that's store on my server under a public_html folder so it can be accessed publicly.
That address is http://example.com/randomlocation/anotherlocation/index.html
on the server that would look like public_html/randomlocation/anotherlocation/index.html
The problem however is that my css, js, and img files to display the page and run it are located on another level outside of the public html section and I'm having trouble specifying the relative or base path to get there, which would be something like:
home/site/folder/randomfolder/anotherfolder/location/styles.css
For Example:
<link rel="stylesheet" href="http://example.com/randomfolder/another folder/assets/css/emojione.min.css"/>
<link rel="stylesheet" href="/home/examplesite/folder/folder/folder/folder/assets/css/styles.css" />
Doesn't seem to work. I've tried all variations of "/" relative paths and can't figure out what I'm missing to be able to pull those files.
Generally when a server has a public_html folder, the server is configured so that only files inside that folder will be accessible publicly via the web. (This way, you can have things like server configs and private files outside of public_html and people won't be able to get to them by just putting the url in their browser.)
In other words, you should move your css/js/images into public_html. You can put them in subdirectories to stay organized, but they should all be under public_html somewhere.
That is purposely not allowed as it would pose a huge security problem on the server. Take a look at this SO question for a possible work around.
php link to image file outside default web directory
I am unable to access CSS file which is located under MVC AREA section.
Here is the full path of the CSS file.
http://mywebsite/Areas/MVC/Resources/dist/css/custom.css
I tried to debug using firebug and it prints the following error message.
The stylesheet
http://mywebsite/Areas/MVC/Resources/dist/css/custom.css was not
loaded because its MIME type, "text/html", is not "text/css".
Although I have specified the text/css type in the link attribute.
I am referring to the css file as below
<link href="~/Areas/MVC/Resources/dist/css/custom.css" rel="stylesheet" type="text/css" />
I have also tried giving the absolute path but still no luck.
If we try to open the above link in browser it is opening correctly and showing CSS but it does not load in the application.
Also the js resouces and images are being loaded in the same folder by using the same path but not the CSS.
Try linking the css file in your main html file. Also, if your system is an user login system then, try linking the css file in that html file which does not require user login.
I've created custom 404 html page for Glassfish 3.1 in case of our application is down due to redeploy or some other failures.
But my 404.html doesn't want to search stylesheet and images files relative to its path (it is placed in domain1\docroot\ ). Every resource is searched in myApp context. That's far from what i want, since while redeploy there would be nothing in that location.
I've embedded styles into html, but this can't be done with images.
Storing images on other server would be to much trouble.
Is there a way to get to the docroot folder?
Finally I've created new application (DynamicWebProject in Eclipse) that contains just the files I needed in 404.html (and of course automatically generated META-INF, WEB-INF folders as well).
Then I've deployed it next to the primary application.
My 404.html file contains following reference to external resources:
<link rel="stylesheet" type="text/css" href="/myResourcesApp/style.css"></link>
Note the first slash "/" in href, which forces browser to search resource in the same domain where 404.html file is.