Downloading file from ubuntu server through html - 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.

Related

apache2 not serving css file despite showing file in directory

I have a website I am trying to host, but for whatever reason, apache2 is refusing to serve the css file I have for my website. I have not change any settings and everything is completely default. I installed apache in the past 2 weeks so everything is clean and fresh.
All I did was copy all the files generated by jekyll from the _site folder and put them into /var/www/html on my server. now, when I go to my website, I can see all the content and the html loads correctly. The links work, images work. but there is no css styling available.
Because the default settings on apache arent that good, i can browse the folder contents. for example, my css file is store in /var/www/html/assets/css/style.css. So, when I access the website by going to https://mywebsite.com/assets/css, I can see the file structure and apache shows that I have a css file in there. but, when I try and click on that file, I get a
Not Found.
The requested URL was not found on this server.
----
Apache/2.4.52 (Ubuntu) Server at xxxx.com Port 443
All other files can be browsed in the folder structure and every file appears to be present, its just the pesky css file that will not load.

Copy website folder and contents to Apache web server

I just started setting up Apache web server to try and test a website I am building. After installing LAMP (I'm on Ubuntu 16.04, if that's important), I copied a folder of HTML and CSS code that I had to test. Here is the folder's contents:
Main folder: testsite
Subfolders: articles, images, CSS, HTML, scripts
Contents:
articles -> .docx files
images -> .png files
CSS -> .css files
HTML -> .html files
scripts -> .py files, but one .html file too
When I went to test the Apache web server, it gave a 404 not found. I'm absolutely clueless as to what could be the answer. I tried renaming the maincode.html file that I had to index.html and putting it in the testsite folder, but it didn't change anything. Is there anything I need to do to fix this?
Here's a screenshot of the 404 Not Found page, with the Developer Console open (in Chrome)
I'm not sure what other information I need to provide, but I'll gladly give any info you need.
Make sure your testsite's conf file has the DocumentRoot property set to the path to your testsite folder. The conf file is probably /etc/apache2/sites-enabled/000-default.conf.

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 to create a website with xampp?

I created this little html file test.html:
<p>It works!</p>
and try to host it with apache. I downloaded and installed XAMPP and started apache. But where to put test.html so i can access it in the browser?
I search now for 30 minutes but can't find anything to start with.
xampp/htdocs folder, this is where index.html takes place.
You can access it via your browser like this: http://localhost/index.html
In order to add/view new files/projects, just add them to htdocs directory and access them via localhost/filename address.
Hope it works :)
In XAMPP root directory you can find 'htdocs' folder. You could create here a new folder for each web that you want to create and put inside your files. You can access in your browswer like:
http://localhost/test.html
http://localhost/NewFolder/test.html

how to run html on python openshift server

I have an OpenShift server running python. However when I call php via SSL the php interpreter starts running. It suggests that there might be a way to run php as well. However, HTML if fair enough for me. Now, I do not know how to be able to reach html files on my server as when I am trying I always get 404 not found. I've read about a solution of placing a .htaccess file:
AddType application/x-httpd-php .html
I am not exactly sure where to place this file but placing in the folder of the .html file still not helps.
Could you please help me how I can make .html files reachable at an OpenShift server running Python? How about php?
Put the .html file in your app-root/repo/wsgi/static folder (or in that folder in your git repository). if you want it to be displayed like app-domain.rhcloud.com/file.html, you will have to use a .htaccess file in your wsgi folder that rewrites file.html to static/file.html