from http://www.example.com/category.html/
to http://www.example.com/category.html
Go to ../app/code/core/Mage/Core/Block/Abstract.php
copy this file to ../app/code/local/Mage/Core/Block/Abstract.php
Find the following line of code:
return $this->_getUrlModel()->getUrl($route, $params);
and replace method getUrl()
with following instructions
/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = array())
{
return $this->_getUrlModel()->getUrl($route, $params);
}
/**
* Generate url by route and parameters
*
* Rewrited method for delete traiking slash
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = array())
{
$return_url = $this->_getUrlModel()->getUrl($route, $params);
if (
$return_url != $this->getBaseUrl() &&
substr($return_url, -1) == '/' &&
!Mage::getSingleton('admin/session')->isLoggedIn()
) {
$return_url = substr($return_url, 0, -1);
}
return $return_url;
}
Go to ..app/code/core/Mage/Core/Model/Url.php
copy this file to ..app/code/local/Mage/Core/Model/Url.php
Find the following line of code:
if ($noSid !== true) {
$this->_prepareSessionUrl($url);
}
and replace method php ($noSid !== true)
to php ($noSid == false)
to make sure that our variable $noSid
is exactly equal false
, result must be like following code examples
if ($noSid !== true) {
$this->_prepareSessionUrl($url);
}
if ($noSid == false) {
$this->_prepareSessionUrl($url);
}
Only if you need redirect from pages with trailing slash to pages without
Edit your .htaccess
file if it exist(used in Apache server)
Find the following line of code:
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Add the following immediately underneath it:
RewriteCond %{request_method} ^GET$
RewriteCond %{REQUEST_URI} !^/downloader.*$
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)$ %1 [L,R=301]
Would welcome feedback on this solution: https://github.com/leytech/Leytech_RemoveTrailingSlashes