As already mentioned, adding the base element just ensures any HTML compliant parser ĺsuch as a web browser) knows what base URL should be prepended to any COMPLETLY relative links (stuff like "image.jpg" and "stylesheet.css"). For web pages if all links to external resources are absolute ("https://example.com/image.jpg", "http://example.com/image.jpg", "//example.com/image.jpg") or SITE relative ("/image.jpg") it is not needed. For emails if all external links are absolute it is not needed.
For the following examples the URL requested by a browser (or other reader) is "http://example.com/folder/index.php" and the base element is not specified. A link to "image.jpg" should result in the browser requesting "http://example.com/folder/image.jpg". A link to "/image.jpg" should result in the browser requesting "http://example.com/image.jpg".
Zen Cart out-of-box currently uses a mixture of COMPLETELY relative links and absolute links. Internally Zen Cart knows what the BASE path is to physical images and the website relative path used to access those resources. Those are the FS_* and WS_* defines respectively in the "configure.php" files. These are used when generating both COMPLETELY relative and absolute links.
Can you guess what would happen in the future if a page was added at "http://example.com/folder/category/my-product-name-456.html"? Zen Cart will still generate COMPLETELY relative links as "image.jpg". The broswer will request "http://example.com/folder/category/image.jpg". But the image is physically at "/username/public_html/folder/image.jpg" not "/username/public_html/folder/category/image.jpg"; resulting in the web server returning a "HTTP 404 - Not Found".
So including the base element helps ensure COMPLETELY relative links generated by Zen Cart are loaded from the correct location. If desired (to avoid having to specify the anchor with the page - such as "index.php?main_page=index#anchor"), one CAN remove the base href from the web page template without any major issues when NO URLs outside the installation root are used.


Reply With Quote

