The URL rewrites of Magento 2 will not be reindexed when rebuilding the index via command line. I recommend using https://github.com/olegkoval/magento2-regenerate_url_rewrites to include the reindex of URL rewrites on the shell. This Magento 2 extensions allows for reindexing all URL…
Removing slash at the end of a URL (Magento 1)
Open your .htaccess file in the Magento root directory and add those lines:
1 2 3 |
RewriteCond %{request_method} ^GET$ RewriteCond %{REQUEST_URI} ^(.+)/$ RewriteRule ^(.+)$ %1 [L,R=301] |
Getting URL parameters (Magento 1)
To get a Magento URL parameter, use the following code:
1 2 |
// URL: http://localhost/project/index.php/admin/sales_order/index/id/123 $id = Mage::app()->getRequest()->getParam('id'); |
Getting a category URL using the category id (Magento 1)
To get a categories URL by category id, use the following code:
1 2 |
$categoryId = 55; $url = Mage::getModel("catalog/category")->load($categoryId)->getUrl(); |
Getting the current URL (Magento 1)
Use the following code to get the current URL in Magento:
1 |
$currentUrl = $this->helper('core/url')->getCurrentUrl(); |
Getting the URL of a product image and display the image (Magento 1)
Use the following code to get a Magento products URL and to display the image on a tempate page:
1 |
<img src="<?php echo $_product->getImageUrl(); ?>" alt="<?php echo $_product->getName();?>" /> |
Using skin, media, … URLs in blocks or CMS pages (Magento 1)
The following 4 examples show how to get the skin, media, base and store URLs in a MAgento block or CMS page: skin: {{skin url=’images/sampleimage.jpg’}} media: {{media url=’/sampleimage.jpg’}} base: {{base url=’yourstore/mypage.html’}} store: {{store url=’mypage.html’}}