Relative Paths not working on apache2 web server - html

Good evening!
I'm pretty new to Linux and Apache and I have a problem with relative paths. I developed my website locally on a Mac, using relative paths and everything worked fine. My files are in a folder with following subfolders:
sites
css
images
Now I'm trying to set up my website on a Linux server running Debian. Almost everything worked out perfectly and I can reach my index.html through the internet. But obviously, relative paths are not working, since I placed my images, my css-file and my other sites in above subfolders, which I try to access with relative paths, but actually they are not working. When I try to access another site (about.html) which is in the sites-folder, I just get this error:
404 Not Found The requested URL /sites/about.html was not found on
this server.
For example, from my index.html, I'm trying to access my css-file with this path:
../css/standard.css
I've also implemented external paths, these are working correctly. I'd really appreciate any help or clues. Thank you very much!

i think the mistake is in the path:
If index.html is in folder where folders "sites, css, etc" are stored, you have to use
css/standard.css
instead of
../css/standard.css

Related

Downloading file from ubuntu server through html

I have my domain pointing at a ubuntu server hosted by amazon ws, and I have my index.html file that gets loaded when someone makes a request to my domain, in the same folder of that index.html file I have another file, and I would like to make it possible to download it from my website. How can I achieve that? I tried with an iframe tag, and giving it src="./myfile.jpg" but the server tries to look for it at www.mydomain.com/myfile.jpg and it can't find it there. Can anyone give me any suggestions?
Btw my files are inside /var/www/html folder, which from what I understood is the default folder for public files on ubuntu.

How to force Github Pages to look at /build?

I'm using create-react-app which is serving its files from the /build folder. Typically Github Pages looks at index.html at the root level, but I'd like to direct it to look at /build for deployment.
I've tried to add "homepage": "/build" inside my package.json configuration, and Github Settings says it's deployed via <username>.github.io. However, the site just shows my README.md file.
Any help is appreciated :)
The problem here is that this is a Web Browser issue, and not a Host issue. When you visit a webpage your browser always looks for the index.html file at the URL so localhost:8080 becomes localhost:8080/index.html.
This means that there are a couple ways to fix this. You could create an index.html file in your root directory and then have that serve up the scripts in the build folder like <script src="build/main.js"></script>
You could also go through the pain and suffering of manually adding /build to the end of the URL. But you don't want users to have to do that, so you could write a script to redirect you there.
Good luck!

HTML and HTAccess

I have been struggling with this all morning and I have not had much luck.
I am trying to get the following stackoverflow post to work: How to remove .html from URL
Here is my file directory with the htaccess file:
Here is my code that works fine using .html
So I went into sublime text and posted the same code into a .htaccess file as shown here (also in my directory first pic):
I then changed my links and removed .html
But I get an error
If anyone could please tell me what I'm doing wrong I would be grateful! Been bashing my head on this all morning
.htaccess is a file used to control access for Apache web servers. It won't affect anything unless you're running and accessing an Apache server. From your screenshots I can see that you're directly opening a file from your hard drive.
Your browser is saying File not found because you're trying to access a non-existent file. The address bar in your browser should say this:
file:///Users/mikegeng/Documents/GitHub/MichaelGeng.github.io/index.html
.htaccess is used by Apache Webserver. You must install and configure an Apache Webserver and access your site through http://localhost for example.
Currently your .htaccess is completely ignored until your site is served by Apache.

How deploy .htm extension on a server?

I want to learn AngularJs from http://www.tutorialspoint.com/angularjs
but an example must be deployed a server. I don't know anything about it.
Please give me some hint about deploy .htm extension file to a server.
Example url is following;
http://www.tutorialspoint.com/angularjs/angularjs_includes.htm
I believe that they just mean placing the files somewhere inside the web root. The web root should be deployed by your local or remote server.
Example:
Download and install MAMP.
Set your root directory as the MAMP root directory in preferences.
Now you can use your own paths -- just follow the example in the link you provided.
https://www.mamp.info/en/
Also, I'm of the opinion that it's good practice to at least use a local web server as opposed to running your website without one.
You don't need a webserver to test the code given in that example. ng-include using relative paths works fine.
However, if you really want to use a webserver for other examples/projects, depending upon your OS, you can use *AMP. where * means
W for windows
L for linux
once you have it installed, place the files in www folder. and access it in browser using http://localhost
Firstly I add my app folder under
D:\tomcat7\apache-tomcat-7.0.67-windows-x64\apache-tomcat-7.0.67\webapps
after I run tomcat server .
And run
http://localhost:8080/an/ht.htm
It is working :) Thanks #ketchupisred #Mridul Kashyap

Tricking IIS 6.0 html web site into thinking it's at the root

I have no idea how to search for this one and perhaps Serverfault would be better but I'll start here.
I have a HTML web site running at the root of one of my webservers. It runs fine and dandy. I needed to make a test environment for it and where I can't run it in the root of the websever. I have to make a directory on the test server. For instance:
http://myTestserver/HtmlWebsite/index.html instead http://myProdserver/index.html
Once I throw it into the directory, most everything breaks. Some images won't load, javascript files can't be found, mass hysteria!
I discovered that the author of said site had used a mix of absolute and relative directory paths in all the files hence why some images loaded correctly.
I can go in and edit all the files to be relative. But I'm wondering if I can make IIS 6.0 think that the web app directory it is in is the root of the webserver. So if I have an absolute path in the HTML like:
<img src="/_support/loadme.jpg" />
it would give me the image for either http://myTestserver/HtmlWebsite/_support/loadme.jpg or http://myProdserver/_support/loadme.jpg.
Can I get IIS 6.0 to do my bidding or am I stuck editing paths?
Unfortunately you'll either have to fix the absolute URL's across the site or run the site in it's own website in the root.
Is there no way you can get a new site created on the IIS6 test server?
You should be able to by using URL rewriting
First you install ISAPI Rewrite, found here: http://www.helicontech.com/isapi_rewrite/
Then you create a config with the following rule:
RewriteEngine on
RewriteRule (.+) /HtmlWebsite$1
What it does is it takes your request, say /index.html, and internally rewrites it to /HtmlWebsite/index.html, which is (ironically) tricking you into thinking you're calling from root when in fact it fetches it from the subfolder.
You might have to add or change the rule if you got more stuff on your test server, but that's the gist of it.