Displaying homepage with Pubby / Apache Tomcat - apache

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.

Related

Absolute path to subfolder

I have apache setup to serve sites in /var/www, and I have many sites in this directory. Now I don't own any of these sites and cannot update any of their content.
The problem is most of these websites use absolute path for their assets like <img src="/img/foo.png">, and apache tries to load them from /var/www/ instead of say /var/www/example1/.
I tried to add a .htaccess to /var/www/ to rewrite every paths to assets to a subdirectory, but I can't find a way to make assets from /var/www/example1/ loaded from this directory and assets from var/www/example2/ loaded from example2 instead of example1.
Is there a way to make this work? I don't really like the .htaccess solution in /var/www/, at first I wanted to use a vHost configuration for every sites but I didn't find how to do it (at least without having a domain name for each site).
Thanks!

Apache - only main domain's root is not working

I've created a new domain and setup a php application on the webroot. All the following requests are working perfectly.
/index.php
/info.php
/?anyting ( Note this, without index.php only query string is working )
/css/app.css
Only the domain's root is not working domian.in
I have created an virtual host for the domain. I tried giving DirectoryIndex index.php also, but still it's not working. There is no htaccess and it's a fresh server setup.
Googled whatever was possible, couldn't get any solution.
And if i hit domain.in it's serving the apache's default page.
If you have an virtual host you cant acces files outside the document root.
Maybe your html files (or others) are in a htdocs folder or something, you cant access htdocs/../

XAMPP is looking for images in htdocs instead of domain folder

I am running XAMPP 1.8.2
Inside of htdocs folder I have a several sites.
Now I downloaded a working website from my hosting/server and found out that the identical copy of that website run on Xampp [http://localhost/mysite] can not find the images.
It is looking for images on
[http://localhost/img/myimage01.jpg] instead of
[http://localhost/mysite/img/myimage01.jpg]
I read some solutions but they all come to pointing the whole thing to [http://localhost/mydomain]
I would prefer if I can tell XAMPP to look for files for every domain from it's own root directory.
How can I do this?
Thanks
The easiest way is to create separate virtual host for each site folder in /htdocs
So you will access the http://mysite.local instead http:// localhost/mysite
There are two things to do:
1. edit C:\xampp\apache\conf\extra\httpd-vhosts.conf (by default) adding something like
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot C:/XAMPP/htdocs/mysite
</VirtualHost>
2. edit c:\windows\system32\drivers\etc\hosts adding
127.0.0.1 mysite.local
restart xampp and try http://mysite.local
You generally can't move a whole website from http://<somedomain> to http://<somedomain>/<somefolder>. Things are bound to go wrong with links between pages in the site and links within pages to images.
Let's say you are displaying images within HTML web pages using image tags like this:
<img src="img/myimage01.jpg"></img>
This will probably work as the browser will look for the img folder in the same folder as the web-page.
On the other hand if your image tag looks like this (note the extra /) you will have the problem you describe:
<img src="/img/myimage01.jpg"></img>
The extra / means the browser will look for the img folder at the root of the domain.

Apache symlink to a folder outside of web root

Here is the folder layout.
/outside is not normally accessible anywhere on example.com
/public_html is the folder for http://example.com
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
Thanks!
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
You can't. As far as I have found out, Apache prevents directives in .htaccess files linking to locations outside the current web root.
You would have to do this in the central configuration:
Alias /outside /path/to/your/outside
You may be luckier with a symlink if you can turn FollowSymLinks on.

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.