Subdomains and Folders - html

Just started a site and I have an /img directory on the main domain. I would like to set up a subdomain(where the file folder is just another one in the main directory) that is able to use the /img folder, but it doesn't work.
The /img and /subdomain folders are on the same level, so to display images in the main domain I type: <img src="img/image.jpg">
and for the /subdomain I type: <img src="../img/image.jpg">
and I get a 404 error for the site: http://subdomain.example.com/img/image.jpg As you can see, I want it to be linking to http://www.example.com/img/image.jpg
Can anyone tell me how to achieve this? I would prefer not to link images to their internet directory (i.e. http://www...) because I would like to modify the sites on my computer and upload them via ftp to my site hosted by bluehost.com.
I'm sure it's just something that I am messing up or don't completely understand. Thanks in advance!

In your folder structure on your web server, create a symbolic link /subdomain/img pointing to the target /img.
In linux, this can be done by:
cd /your_web_folder/subdomain
ln /your_web_folder/img img -s

Do not use subdomains for asset management. From an enterprise perspective you will end up with hundreds of subdomains and have no idea what each represents. I know this must sound absurd, but I have seen it happen.
I would strongly recommend using a well thought out directory structure that balances asset types against versioning information. I would also recommend using a content distribution system, such as the edgesuite networks.

Related

Uploading an XAMPP subfolder to a web server

I'm completely new to XAMPP, and don't know much more than HTML and CSS. I've put my website into a subfolder in htdocs called test. In my HTML, I have relative links that look like /test/path/to/image.jpg.
I was planning on uploading the subfolder test to a server using FTP. My question is, will I encounter any problems because of the way I have my links formatted? When my website is live, I'd like for the URL to look more like example.com/path/to/image.jpg rather than example.com/test/path/to/image.jpg. Is it better to use ../ to define my paths instead?
I've seen some similar questions that required people to use the .htaccess file, but I can't find that/don't know how to use it. Again, sorry for my total lack of knowledge on this; I'd be super grateful for any help.
/test/path/to/image.jpg
Isn't a relative path/link - it is absolute, meaning the web server would try to serve the file from http://www.example.com/test/path/to/image.jpg. If you would like that file to be served using a relative URL, you should use:
path/to/image.jpg
Which will serve the file relative to the page that is requesting it. If the requesting page is in the test directory, and document root is the test directory, the server would deliver http://www.example.com/path/to/image.jpg.

How can I simply expose local .html files via web browser using an application server (Glassfish)?

Lets say I have a directory of .html files, accessible by the app server, and I want to display to users so they can access them with their browser:
/import/tps-reports/index.html
/import/tps-reports/report1.html
/import/tps-reports/report2.html
Is there a way I can expose the tps-reports directory to do this so that a user can access them via:
http://www.example.com/tps-reports/index.html
http://www.example.com/tps-reports/report1.html
Also, keep in mind that index.html may reference the other pages:
Report 1
So those links need to work as well.
Here is a possible answer:
http://docs.oracle.com/cd/E19776-01/820-4496/geqpl/index.html
You can set up an alternate doc root so that certain URI patterns point to different paths.
The examples are only really showing relative paths though...I wonder if its "ok" to use this to reference local file systems.

Is it OK to have more than 1 index.html on your website?

I have a index.html on my root folder of a subdomain
i.e. example.example.com/index.html
and then I made a second folder (which is located in the root folder)
example.example.com/folder/index.html
Is this good/recommended?
PS I'm pretty new to this so I have a follow up question. Does this have tie in to sitemaps in a big way and do people usually use an app to do the their "sitemapping" for them?
That's fine, but there should only be 1 per folder. The index.html is the file your webserver will serve up if another is not specified, so it is normal to have one in each directory.
As far as creating the sitemap, there are a lot of tools online that will create an XML sitemap for you and that is what people usually use.
Its ok to have multiple index.html files, may be some experts will say its not a recommended way. But in my point of view as long as you know that what's going on you can have tons of index.html .

How to set completely relative URLs

I'm having problems setting URLs in a particular situation. I have a Dreamweaver template, that uses the usual relative to domain URLs (e.g. "/images/foo.png"). This works fine on the server, but in the local environment, it has issues, as it thinks the name of the network drive it is on is the domain, rather than the folder it is in on the drive.
So where as it should be "file://networkdrive/localsite/images/foo.png" it's "file://networkdrive/images/foo.png", this is obviously causing broken links, and if I use other relative URLs, such as "../images/foo.png" then I will have to amend the links every time I make a page that drills further down in the site structure.
I did have one solution, creating a mapped drive pointing at that folder, then "Z:/" was the first layer, and it all worked. That was until our communications team needed to see it on their Macs, Macs can't do drive letters as I've found from Googling, so I'm back to the same problem as before.
Any ideas on how I could force the URL to be correct when using "/images/foo.png"? This will save me a lot of headaches when creating pages if it could be done.
Run a local web server, like Nginx, lighttpd, Apache, or Python’s out of your project directory:
python -m http.server # Python 3
python -m SimpleHTTPServer # Python 2
This comes closest to a real environment for development, and it’ll allow you to test things like server-side code and Ajax.
Alternatively, you can use relative URLs everywhere, and one <base> tag per page.
<base href="../">
Don’t.

deploy website to cd - paths

what's the best way of porting a static HTML website to a CDROM, to allow users to insert the disk, copy the files off, and then run the site "offline", as it were.
what sort of path structure should i use? at the moment all of the assets are like:
file:///C:/Users/User/Desktop/MySite/index.html
which obviously isn't very portable
thanks for any info
You should use relative paths, like
index.html
and
images/img.gif.
If you have many absolute links, search for "file:///C:/Users/User/Desktop/MySite/" and replace all with "" (or "./", to make things clearer). Notepad++ can search across all files of one directory.
To make things even clearer, create a subdirectory with all files and more subdirs and optionally an index.html in the root directory, so the user only has to copy one folder (plus one index.html).
You can try to use portable web-server application.
This application allow to run any websites on any drives (USB-Flash or CDROM). The main advantage that you shouldn't to change links from absolute paths to relative. Also, the application will open your sites if that uses a database or PHP.
For example: XAMPP (Portable Web Server) and many others.