getBaseUrl – Magento URL Path

When developing in Magento and playing arround with Magento Themes there is some functions you should know.

If you want to get the source url of an image, javascript or file, call one of this functions adding your own path at the end.

Under every function there is an example of the output value:

http://example.com/

http://example.com/js/

http://example.com/index.php/

http://example.com/media/

http://example.com/skin/

Tags:

5 Responses to “getBaseUrl – Magento URL Path”

  1. Eric December 14, 2011 at 4:59 pm #

    Rick, great site and resource.

    Wondering if there is a source URL for Magento categories?
    Example: [code]<?php echo $this->getCategoryUrl($_category)?>[/code]

    My site is giving certain visitors an SSL Certificate error. Found that not all my links are converting to the secure https link. My host has verified the certificate placement. Your functions above have helped with converting most of my links to https.

    Thanks!

    • Rick December 14, 2011 at 5:47 pm #

      Hi Eric,

      Thanks !

      Try this:

      [code]
      <?php echo Mage::getModel("catalog/category")->load(5)->getUrl() ?>
      [/code]

      Let me know if it works 😉

  2. mahesh March 29, 2012 at 12:02 pm #

    Is there any method get the URL link for subsites/subdirectories

    like

    1) http://mycom.com/store1
    2) http://mycom.com/store2

    • Rick March 29, 2012 at 12:14 pm #

      Have you tried to use the method above? I think it’s smart enough to know if you’re in the store1 or store2.

      Let me know if it works,

      Regards

  3. Pablo Gancharov March 30, 2013 at 3:26 pm #

    mahesh:

    No it isn’t.
    you should use:

Leave a Reply

Add <code> Some Code </code> by using this tags.