SEO Friendly Tag URLs for Your Magento Store

By default, you would have a tag URL such as this for your Magento store:

http://www.example.com/tag/product/list/tagId/3/

While it’s perfectly static, it doesn’t look good without tag names in the URL nor does it inspire trust. We want it to be more neater as:

http://www.example.com/tag/royal/

It’s actually a very simple problem that’s ready to be solved if you are willing to spend $39 bucks. Iceberg Commerce has the exact solution: Magento SEO Product Tag Urls

Simply purchase the package, download it, uncompress and upload the app directory to your store installation. It’s upgrade-proof because they are well separated from the rest of the system. You don’t even have to overwrite any files.

Clear your Magento cache and you would see SEO-friendly tag URLs all over your store: individual product page, tags list page, etc.

They’ve got also a lot of other interesting and useful extensions for your Magento store.

Malicious / Spam Search Terms in Magento Popular Search Terms

If you’ve got a fairly popular Magento store, you’ve probably got the problem of spam or malicious search terms showing up on the Popular Search Terms page. It’s ugly and you want to get rid of them once and for all, but at the same time leaving legitimate search terms performed by good-will users intact.

Of course you do. Me too. Look at this:

Magento store spam searches

So how to delete spam search terms from Popular Search Terms page?

What I’ve done is to edit the /app/design/frontend/default/your_theme/template/catalogsearch/term.phtml until it looks something like this:

		<?php
		$princessly_search_term = $this->htmlEscape($_term->getName());
		if (strpos($princessly_search_term, '%') !== false
			|| strpos($princessly_search_term, "'") !== false
			|| strpos($princessly_search_term, '`') !== false
			|| strpos($princessly_search_term, '=') !== false) {
			continue;
		}
		?>
            <li><a href="<?php echo $this->getSearchUrl($_term) ?>" style="font-size:<?php echo $_term->getRatio()*70+75 ?>%;"><?php echo $princessly_search_term ?></a></li>

The PHP function strpos() checks if a specific character is existent in the string $princessly_search_term which contains the originally raw search phrase. If it does, it’s not displayed (continue to the next phrase and check it to see if it does).

Most malicious / spam search attempts contain ‘%’, “‘”, or ‘=’ which normal users wouldn’t use in a legitimate search for your products. Now the Popular Search Terms page is a lot more clean and user friendly.

Force URL Trailing Slash in Magento for SEO

The default Magento installation allows for URLs with and without trailing slashes. For example, the customer-service page is accessible at both URLs:

  • http://www.example.com/customer-service
  • http://www.example.com/customer-service/

This is really bad for SEO. The good practice is choose one of them as the uniform / canonical URL and redirect the other one to it in 301 HTTP code (Permanently Moved).

Then you should use the uniform one as the only URL to that page consistently across you entire site and across your link building endeavors.

We’ll use the second one here – forcing the URL to have a ending slash.

How to Force a Trailing Slash for Magento URLs?

The solution is simple. Just add this snippet immediately below the line of “RewriteEngine on” in the .htaccess file at the root of your Magento site:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !(.*)\.(html|shtml|php)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]

And all URLs without a trailing slash such as /customer-service would be automatically redirected to customer-service/ that’s with a trailing slash.

Optionally – get rid of ‘.html’ for product pages’ URLs

You may also want to get rid of the trailing ‘.html’ for product pages and category pages in your Magento admin panel by “System” -> “Configuration” -> “Catalog” -> “Search Engine Optimizations” or you would have URLs such as: http://www.example.com/blue-widget.html/ which is undesirable and said to cause crawling problems for Googlebot.