Results 1 to 10 of 21

Threaded View

  1. #14
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: Is <base href tag necessary?

    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.
    Last edited by lhungil; 8 Nov 2015 at 09:36 AM.
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

 

 

Similar Threads

  1. base href problem
    By cricles in forum Upgrading from 1.3.x to 1.3.9
    Replies: 3
    Last Post: 20 Jul 2010, 06:34 AM
  2. SSL Problem (Base href???)
    By DaveS in forum General Questions
    Replies: 24
    Last Post: 4 Sep 2009, 06:23 PM
  3. Base HREF https issues
    By mikebackhouse in forum General Questions
    Replies: 38
    Last Post: 27 May 2009, 05:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg