Setting Up A Html Page On A Server - html

I am trying to learn how to set up a html page on a server, which i have done but an index page appears, I do not want this page to appear i would rather my home page to appear.
I am only learning how to do this so i have used a free web host.
web address: http://testingmyfreewebsite.comxa.com/
My file manager looks like this
The subPages and Css folders were created by me and they contain the css and other pages to my website.
i would really like to know how to remove the index page i am open to many methods.

There are three commonly used default page names that you can use on most web servers:
index.html
index.htm
default.htm (on some Windows servers)
It's a good idea to stick with index.html or index.htm on most servers, as default.htm is most often used on Windows servers, and isn't as common as it used to be.
If you're going to put other pages inside of folders (or directories) each folder should have an index.html inside of it as well if you're relying on the url to direct the user instead of hard coding it in.

Related

Multiple index.html files inside folder structure

I just came up with an idea. Instead of using an .htaccess file to remove .html from the URL, why not just use a simple folder structure and in each folder add an index.html?
For instance:
example.com/index.html → Home
example.com/about/index.html → About
Now simply use a hyperlink on the homepage to the about folder, since typically index.html files are opened automatically.
The upside of this kind of navigation, is that it would be easily possible to create sub pages with no crazy database / .htaccess setup.
Now my question is: is there any reason not to create a webpage like that and is it legitimate to use multiple index.html files?
I appreciate all the help.
With the index.html route, there would be three URL's that can access the same page. For example for an about page:
www.yourwebsite.com/about
www.yourwebsite.com/about/
www.yourwebsite.com/about/index.html
Using the .htaccess file would likely give you more benefit from an SEO perspective. You can tell the search engine which one to use, by using 301 redirects. See more about how Google does this here:
https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html
Of course you could set up your website using folders and index.html's, and still
use the .htaccess file to take care of the SEO. But, depending on your sites size and structure, this might be more work.
The only downsides would be having to create a folder in addition to a file whenever you want to create a new page, and having to take more time to navigate into a folder in order to edit a page.
As long as you are using Apache, or a similar server software, multiple index files will function normally and be served from each folder.

../ For Parent Directory Not Working HTML

All,
I did a bit of research but haven't found an exact thread or resolution to this issue.
I am using express in this webapp, Chrome Version 60.0.3112.113, and Win 10 Version 1703.
I am currently developing a site where I want to use a hamburger svg for mobile navigation. This is how the html sits for the "topbar"
<div id="topbar">
<img src="../images/hamburger.svg" alt="ham">
</div>
And here is the file structure:
https://puu.sh/xxDih/c842297b54.png
According to the structure, I should only need to do ../images/hamburger.svg, but when I do that, it comes up with a 404 error in the waterfall. I have run into this issue multiple times doing any sort of HTML sourcing into parent directories, but in JS files it works fine.
I'm not exactly sure what the issue is.
For the express server,every uri are processed by the express contains resource url and request url.
Request url(api) is refered to your express api config
resource(image, js, css, html...) is relative to your static server's root directory which was defined by using express.static(root_path).
That's what I want to say.
I noticed that images folder, node_modules folder, and pages folder are all in the same directory, and css is under the pages folder.
"../images/hamburger.svg" is the correct relative path from the pages folder, but being (big red flag) the node_modules is at "../node_modules/" I'm thinking that the server is serving from /pages/ folder, the servers root directory. meaning anything above the /pages/ folder will not be shared.
Clearly you do not want to share out ../../../windows/system32/ or the user documents etc. To prevent sharing those the highest directory you can access from the html page through a browser is the server folder being used. I'm thinking /pages/home.html is localhost/home.html and localhost/css/ is your css directory.
Programs running on the server can access files above the served directory, but the browser can not. "/node_modules/" should be outside of the servers root directory.
I realized this is an issue with express itself.
If (in this case) you have your index.html as express.static('./pages'), then it can't see anything above pages and considers pages as the working directory.
Me, coming from React (which stupidly was the first thing I learned even before basic JS), wants to put all the pages in one folder, which I think would make sense.
The workaround I did, which may not be optimal, was by putting index.html as a sibling to pages, css, and images in the src folder. Then in index.html, it has a meta tag as follows: <meta http-equiv="refresh" content="0; url=./pages/home.html" /> to redirect to the home.html page.
Again, this may not be optimal, but for a kinda OCD guy like myself this makes sense.
Update:
What we ended up doing is to have index.html be a static page, and then load the individual pages in an iframe. This website is mainly for information and has no database (yet), so there won't be much to process. Here's the new file structure that works.
http://puu.sh/xy5Dw/4dbc72ec06.png
src is now our working directory (express.static('./src')) and everything is detailed within there.
Once we do include a database, it will at most be 10 values in the server and will be using very basic requests, nothing crasy.

HTML-Reloading web page takes me to main page

I am creating a website and hosting it myself via IIS. I am trying to traverse pages but it's not really working.
This is my code that will go to my "serivices" page. However, when on this page the URL does not change and when pressing reload I am taking back to the home page.
Our Services
So, for example, since my page is www.aasoftwaresolutions.com, when I click "Our Services" it should take me to www.aasoftwaresolutions.com/services.html. It doesn't do this. It will show the webpage but it will still have URL www.aasoftwaresolutions.com and when I press reload on the browser it takes me to the homepage rather than keeping me on services.
Here's my file structure:
F:\Website\ (base directory for website)
F:\Website\html\ (where all the HTML is)
Any ideas?
start directory:
it's for example: index.html
Our Services
the directory is here (for example).
F:\Website\ (base directory for website) \index.html
with this you are going to:
F:\Website(base directory for website)\html\services.html
with this ..\ stand back a folder ago.

Hiding page names in the browser

When we launch a website, we usually see webpage name (menu.php or admin.aspx) but I would like to hide that name and show only virtual path or just website name. I don't want it for the first page because I did that with default.aspx but I want to implement it for the whole website.
Showing www.abcd.com/faq/ instead of www.abcd.com/faq/faq.html
Note: My code is not MVC code and server is Apache.
Use .htaccess to rewrite the URL. Millions of tutorials are out there for that ;)
What you are asking is achieved using (for xampp, wamp, lamp or any other apache powered webserver setup) htaccess rewriterules. The rules take the URL and break it into parts that can be modified or used as variables to feed other pages - whilst still keeping the URL you typed. Neat huh!
Showing www.abcd.com/faq/ instead of www.abcd.com/faq/faq.html
call the file placed into the folder faq simply index.html (not faq.html) and then www.abcd.com/faq/
will display the page without the filename. (Make sure, you have defined index.html as a valid Directory index.)
There are more options with using mod_rewrite etc - but since you seem to use a prety static directory based navigation layout, that would be the easiest way.

How do I make a hyperlink go to a page on another website?

When creating the html files for my website, I had no problem understanding how to create links so that users could navigate between pages. For example, this worked fine to send someone to the about page:
ABOUT
I'm having issues upon uploading the html files to my web server.
How, do I get About link to send the user to: www.blahblahblah.com/about ?
My landing page has been renamed index.html.
You need to add http:// in the href to go to a page on an external site:
About page on blahblahblah.com
This is because when you simply link to it without the http:// in front (hyper text transfer protocol) it is trying to go to the page "www.blahblahblah.com" which obviously does not eixst on your server. When you add the http://, the browser knows that it is another website and therefore will bring you to the external site.
Your web server will be configured with a "document root" directory. Usually this is the directory where index.html is located. Place your about.html in the same directory, and the link you provided will link to it if it is served from the same URL-path (that is to say, it's not in a sub-folder). If your files are indeed in the document root, you may prefix your link href attributes with a forward-slash, which indicates that the path is relative to the document root.
As noted in the previous comment, this technique only works for pages hosted in the same directory as each other, on the same host. If the files are in different directories, you must start with the slash, and if they are on different hosts, you must include the full domain and path.
This is what he meant:
<input type="button" value="SampleText" onClick="window.location='http://www.blahblahblah.com/about';">
and this will open it in a new window:
<input type="button" value="SampleText" onclick="window.location='http://www.blahblahblah.com/about';" target="_blank">