myPage.com instead of mypage.com/WebContent - apache

I have created my webpage in eclipse as Dynamic Web Project and uploaded the WebContent folder to the server (WebContent contains index.html js, imgs and css). When I call myPage.com, it works only with the url myPage.com/WebContent. Afterthat I have uploaded the content of the folder WebContent directory to the server root. Now when I call myPage.com, it display empty page. mypage.com/index.html display empty page too.
How to upload WebContent, sothat the index.html display woithout using WebContent in the url?

This can be achieved by:
Using URLRewrite. This thing changes URLs according to the patterns you configure. More to read: http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
Using redirects in the root folder - if someone requested the folder, it automatically sends you to another folder. This can be done by placing index.html in root folder containing: <meta http-equiv="refresh" content="0; url=http://mypage.com/WebContent" />;
Using Virtual Host - description for Tomcat 6.

Related

How can I get my Hostinger shared hosting server to execute .htaccess file in hidden /.well-known folder?

I am on a Hostinger shared plan, trying to set a CORS header on a single TOML file that MUST reside in the public_html/.well-known folder. I have an .htaccess file in the ".well-known" folder but the Apache server will not process it.
However, if I rename the ".well-known" folder to "well-known" (just removing the period), the .htaccess file works and I can set whatever headers I want for files in that folder.
At this point I have deleted my entire site and replaced it with an extremely simple one in order to try and make this work.
The current file structure is as follows:
public_html
/.well-known
.htaccess
test.toml
/well-known
.htaccess
test.toml
index.html
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Apache Header Test</title>
</head>
<body>
Apache Header Test
</body>
</html>
.htaccess (identical in the ".well-known" and "well-known" folders)
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
test.toml (identical in the ".well-known" and "well-known" folders)
Apache Header Test
When I navigate to /well-known/test.toml, the response is served with the CORS header set and a content-type of "text-plain", and the toml file contents show as plain text in Chrome, which is the desired and expected behavior for both folders.
However when I navigate to /.well-known/test.toml (with the period), there is no CORS header, it shows a content-type of "application/octet-stream", and the toml file downloads instead of showing in the browser.
What exactly is happening here and how can I fix it? Thank you!
After finally asking the right question to Hostinger (thank you MrWhite!), they confirmed that making changes to the /.well-known folder is not possible on a shared hosting plan. Here is the official response I received:
The .well-known directory is server-default, so that is why overriding and making changes to it is not possible on a shared hosting plan, as important data/information is stored there.
To make meaningful changes in this directory, you would need root access, which is only available on our VPS plans.

Apache change favicon for certain directory

I'm having a problem with apache that it only looks in the root directory for favicons. I need a separate favicon for a specific directory on my webpage. Below I will draw an example
- favicon.ico
- index.html
- / Folder
- favicon.ico
- index.html
- index2.html
I want /index.html to have a favicon of /favicon.ico and I want /Folder/index.html and /Folder/index.html2 to have a favicon of /Folder/favicon.ico. (Edit: I do not want to specify at the top of each file, there are too many to make that practical)
I tried just putting a favicon.ico inside the sub-folder but it didn't do anything different. Thanks
Simply add the following code to the <head> element of each HTML file were you want to change the icon:
<link rel="icon" href="http://example.com/favicon.png">
The Path needs to be adapted in the code snippet
What is important is that you have this snippet in your HTML files and then you just update the path to the icon you want.
This link might help you:
https://www.javatpoint.com/how-to-add-a-favicon-in-html
Also if you search google for your problem you will get many docs and examples.

script/stylesheet links in index.html file served from wwwroot return 404

I am retrieving an index.html file within an action with that route:
/services/parts/{number}
from wwwroot folder
...
return ContentResult(html, "text/html");
In the wwwroot folder I have this structure:
wwwroot
|
---services
|
---parts
|
---1
|
---index.html
|
---2
|
---index.html
// and so on 3,4, ...
As I said before, retrieving the index.file and returning it is no problem, but all links/scripts in the index.html file embedded can not be loaded so I get a 404 for those links.
Then I checked why a 404 for each link:
Requested url: URL:http://localhost:60000/services/parts/2/~/styles/vendor/bootstrap.min.css
The stylesheet link in the index.html:
<link rel="stylesheet" type="text/css" href="~/styles/vendor/bootstrap.min.css">
Changing the stylesheet link to:
<link rel="stylesheet" type="text/css" href="styles/vendor/bootstrap.min.css">
Result in that requested url, no big change...
Requested url: URL:http://localhost:60000/services/parts/2/styles/vendor/bootstrap.min.css
Why does the asp.net core framework try to download the bootstrap.min.css from the route services/parts/2 and not from the styles/vendor folder being subfolders under the wwwroot folder?
How do I fix that correctly?
First, the ~ is not actually supported by browsers as part of a URL. It's a filesystem carryover that ASP.NET will replace with the document root portion of the URL. However, that only happens if ASP.NET processes the HTML, which means it has to be an ASPX, CSHTML, etc. If you just dump some HTML to the response, then that doesn't occur, and the ~ remains, resulting in a 404.
In the second attempt, you're using relative URLs. When you have a URL like styles/vendor..., it will be affixed to the end of the URL in the navigation bar, hence the /service/parts/2/styles/vendor....
If you want to specify a path from the document root, you need to prefix your URL with /. In other words, /styles/vendor.

Displaying homepage with Pubby / Apache Tomcat

Does anyone know how to go about displaying a custom homepage when Pubby is the root of Apache Tomcat?
My current setup is \Tomcat 6.0\webapps\ROOT\ <- Pubby folders WEB-INF and static are in this folder.
Whilst creating custom pages for e.g. localhost:8080/About is completely fine, (I just create a folder within my webapps folder called "About", and put my index.html in there), I don't how to get a custom index.html to display when I navigate to localhost:8080
I've tried sticking index.html files across my directories, but localhost:8080 won't resolve to any of them.
Thank you!
The index files for http://localhost:8080/ will be defined in $CATALINA_BASE/webapps/ROOT/WEB-INF/web.xml with defaults taken from $CATALINA_BASE/conf/web.xml
Assuming the ROOT app does not specify any welcome pages then an index.html placed at $CATALINA_BASE/webapps/ROOT/index.html should do the trick.

File Not found - very basic web dev help

I have not done any web dev before. I got my Apache server running on mac OS X, and set up a virtual host at /Users/dan/webapps. So, when I go to http://localhost/ in my browser, my index.html in the webapps folder shows up, as expected.
I then created Users/dan/webapps/temp/ folder, and put a flash app in there, let's call it "test.html", along with the required "test.swf". I restart the server. However, when i put http://localhost/temp into my browser, I get File Not Found. How do I make the browser able to go to that directory, and when it goes there, have it start test.html. I am using Safari. Thanks.
you should type: http://localhost/temp/test.html
a full path to your page,
Or you can change the name of your page from test.html to index.html and it would be loaded when you enter http://localhost/temp/, since the default DirectoryIndex is index.htm or index.html
Create a .htaccess file in Users/dan/webapps/temp/, and add the line:
DirectoryIndex test.html
This will make apache look for test.html when someone accesses the directory. Make sure permissions/ownership allows your webserver to read this file.