I lack the know-how with IIS and IIS manager to even have the proper google terms here, so I hope you'll keep that in mind if you're tempted to click that downvote button.
Thanks.
Okay, so I have an angular application that I just moved over to an an IIS server after developing it locally, without using IIS.
The IIS-based copy of the application works, in that it will serve index.html as expected. Unfortunately, links to external files (.ccs, .js, etc) are all broken.
The application lives in this folder:
\\iis.dev.local\c$\inetpub\wwwroot\the-application
And it's .css file lives here:
\\iis.dev.local\c$\inetpub\wwwroot\the-application\css\main.css
As originally written, the link to that .css file, which we'll call "link 1":
<link rel="stylesheet" href="/css/main.css">
Which worked fine in development, but doesn't work on IIS.
However, this does work, which we'll call "link 2":
<link rel="stylesheet" href="/the-application/css/main.css">
See how I had to add the folder that the application itself sits in? Which is strange, because relative to index.html, "link 1" should be correct--but it isn't.
How can I convince my application that its base url should be the folder it's sitting in, and not one level above?
Random partial guesses and/or useful information?
1) The application sits in the default application pool.
2) Something, something web.config?
EDIT: screwed up some paths.
Try using the <base> HTML Element to set the root.
https://www.tutorialspoint.com/html/html_base_tag.htm
In your example it would be:
<base href="https://www.the-application.com" />
Then the rest should flow, with relative paths.
When developing on your local machine you are most likely running under a Virtual Folder under the DEFAULT website.
When you move to a server you are now running at the ROOT of the site.
Options:
Create a new site on your DEV Machine at the Root of IIS. Then use this path to test your site. When you migrate to production the paths will be the same.
Create a variable with the correct path, and if running LOCALHOST (in the url) use one path, else the other. Use JavaScript to add the link to your HTML (Something I have done with a JavaScript site under IIS for Cordova Development).
Change your page extension from .html to .aspx (yeah I know who wants to do that...) then change your links as follows. (I had to remove the starting < and ending /> in the code below, it would not format in the post)
link rel="Stylesheet" type="text/css" href="<%= ResolveUrl("~/css/main.css") %>"
When you browse your source afterward you will see... (or when you navigate to sub-pages it will put the correct relative path in place for you)
<link rel="Stylesheet" type="text/css" href="css/main.css"/>
Related
I have got my website to work localhost on Windows Server 2019 dedicated IIS 10, but I am trying to reach my site on the internet using my IP address so like this:
http://142.11.195.158/ but my CSS file and JS files are not loading.
and is that why i cant load my CSS and JS files because I am using the IP address to view the website remotely?
I have allowed anonymous access to enabled to my Apppool aswel. my mime types are setup of having these files.
Where am i going wrong?
In my index page im loading the images as so:
<img src="img/service-icon/diamond.png" alt="Service 1">
and
<img class="slide-img" src="~/images/image3.png" alt="Slide 3" />
Im using MVC core 3.1
The files are pointing to here external files:
https://142.11.195.158/css/youtube.css
In my root folder in IIS the css and js files are inside wwwroot, this is how the website got published from visual studio, so my root is wwwroot and inside here is the published css an js files inside wwwroot
--wwwroot (website)
--wwwroot
css
js
Static files is ticked also when i installed Web Server or IIS
I think for the moment, you need to remove this line:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
I am a newbie at working with nodeJS and especially with the framework Sails.
I did my research and found that with sails you just need to put CSS-files under the the folder "assets" and call them directly with the URL, e.g. if I put the file custom.css in the folder "assets/foo" I should be able to access it via the URL "localhost:1337/foo/custom.css".
The problem is that my local server throws a 404 Error not being able to find the files, but strangely when I deployed the app to Heroku it works perfectly and I am able to access the css files.
Why is this not working locally?
Welcome to Sails! CSS is served automatically if you put it in your assets/styles folder. Your JS should be in assets/js folder as well. This way you can access it like localhost:1337/assets/js/myjs.js.
In your view - if you don't want to serve it everywhere with a layout - just put your tag like this: <link rel="stylesheet" href="/styles/myawesomestyle.css"> or <script src="/js/mypowerfuljs.js"></script>.
Remember, everything in assets will be made publicly available.
I really recommend that you read the docs HERE.
We all know that we can include custom JS/CSS in theme portal_normal.vm as:
<script type="text/javascript" src="$javascript_folder/custom.js" charset="utf-8"></script>
<link type="text/css" rel="stylesheet" src="$css_folder/your_custom.css"></link>
Both the variables $javascript_folder and $css_folder result into an absolute URL.
http://content.liferay.com/4.3/misc/theme-api-4.3.0.html
In my situation, the liferay runs behind a proxy server and hence, these absolute URLs are causing me a trouble and the js/css files are NOT getting loaded in the browser.
Not only the files added using these velocity variables, but some other theme related files (main.css, main.js) are also not loaded into browser with server absolute URLs.
Is there a way to force theme to use relative URLs instead of absolute?
Thanks
Absolute URLs in general are huge pain in Liferay. Can you afford to specify properties in portal-ext.properties:
web.server.host
web.server.protocol
web.server.port
?
If so this may help you - it should make absolute path respect your proxy configuration. Thought it is not always possible - for instance when you need to access LR instance both through proxy and directly (think e.g. intranet vs extranet).
If you're using Apache's mod_proxy and forward through http, I suggest that you take a look at the ProxyPreserveHost On directive. This forwards the hostname actually used to tomcat (and thus, Liferay).
Another alternative is to use mod_jk or mod_proxy_ajp - they forward the traffic through the ajp protocol, which does this automatically.
In short: Unless otherwise configured (see pdolega's answer) Liferay will use the hostname that a request has been made to. This is determined by Tomcat. And if tomcat only gets proxy requests to an internal host, that's what it resolves to.
The one caveat though is that sometimes there's no request (e.g. in background tasks, emails etc.) and it might be worth to use the same hostname on both ends: Think of an email notification of a message board post: If this goes to intranet- and internet-users, which hostname do you expect to be in the link that is sent out to both kinds of users simultaneously.
I'm trying to use Video.js to display a small video on our team sharepoint page (Sharepoint 2007). It works great, but the 'Do you want to view only the webpage content that was delivered securely?' alert always displays when you navigate to the page. The security settings on the computers cannot be changed, but is there any way I can avoid this alert being displayed?
Thanks in advance for any help.
Thanks,
Simon
This is happening because the page being accessed is served over HTTPS, but some content loaded remotely comes from HTTP. If you're using the Video.js CDN-hosted files, you'd want to change the include tags to look like this:
<link href="//vjs.zencdn.net/4.3/video-js.css" rel="stylesheet">
<script src="//vjs.zencdn.net/4.3/video.js"></script>
These are called protocol relative urls, meaning it will use whatever protocol the page is to load the files.
Hope that helps!
I come from CodeIgniter where files/folders are typically protected this way:
.php files
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
index.html files
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
I guess can be possible with .htaccess or hard way but, how can be done using Laravel 4? is there a way using its 'standards'?
Edit: Is a project built for shared hosting.
/assets/{css, img, js}
/packages
/system/{app, bootstrap, vendor, index.php, .htaccess, favicon.ico}
You need to make a file .htaccess, after that you need to add the following:
# Disable Directory Browsing
Options All -Indexes
You should set up your application so that everything outside of the initial public directory is outside of your document root. That's one of the reasons why Laravel actually ships with a public directory. Typically most people will symlink this directory to the document root. Anything inside public is, obviously, public. If you'd like your assets directory to be inaccessible you could opt to use htaccess or an index.html file much like how you've described.
If, for whatever reason, you need to shuffle some things around and have your actual application files within your document root then you'll need to implement some form of security if you see the need. This, again, could either be using htaccess or an index.html file. Typically a htaccess approach is simpler. If you wanted to protect the app directory you could drop a .htaccess file in there that looked something like this.
deny from all
I have provided a similar answer to this type of question here: Laravel image gallery logic
In principle - you should store all your assets outside of public - and use PHP readfile() to securely serve them to users as required.
The answer might be a year late, but I thought it might help others who want to tackle something similar.
Check out Kelt Dockins' post here. The Codesleeve Laravel Asset Pipeline would allow you to have your assets folder outside your /public folder, securely.