Within Magento you have the option to add URL Rewrites (also commonly called Search Engine Friendly URLs) to make your weblinks more readable to both search engines as visitors. Sometimes issues arise when using these URL Rewrites, for instance when a cache is out-of-date. This guide helps you solve these issues.
Within Magento, the URL is built up following strict rules: The URL is built upon with segments, and each segment is separated with a slash (/). The first segment refers to the Magento module that is used to serve the webpage, and the other segments refer to parts within that module. For instance, the following URL might be used for a product:
Here the "catalog" segment refers to the Catalog-module (part of the Magento core), while the other segments indicate that a product with ID 177 should be displayed on the page. A category URL looks similar:
Now, these URLs might be useful to programmers and administrators, but to visitors (and there for search engines) these URLs look like nothing of value. The concept of URL Rewrites allows you to turn these URLs into friendly URLs instead.
Within each category or product there is a field called URL Key. The value of this field is used to build the friendly URL. It is there for recommended to always enter something useful here. Also note that the URL Key needs to be unique for all your products.
The easiest way to come up with a good URL Key is to take the products title and translate it into a code which is allowed for URLs: This includes alphabetical characters (a till z, preferably lowercase), numerical characters (ehm, numbers) and some extra characters (-_,.).
The URL Key is stored with the product properties, but also in a separate listing of URL rewrites. This listing can be managed through Catalog > URL Rewrite Management, which allows you to overwrite the default generated values, for instance per Store View when dealing with multilinguality.
If you remove the entries from URL Rewrite Management, the SEF URLs pointing to your product will become invalid. As soon as you refresh the URL Rewrites index (see below), Magento will check for corresponding URL Rewrite entries and create them if necessary.
Within the Magento configuration (accessed in the Magento Admin Panel through System > Configuration) there are some relevant settings that determine what the eventual Search Engine Friendly URL looks like. Let's take a look at some of them.
Of course more settings are related to SEO, looking at how important content in general is, but in this guide we stick to the URL settings.
As soon as you make changes in the System Configuration, or you remove entries from the URL Rewrite Management page, you'll also need to refresh the Catalog Url Rewrites index. With Magento 1.4 you can browse to System > Index Management and select the Catalog Url Rewrites to refresh them.
Sometimes when you make changes to your products, or enable a certain extension, Magento might start to rewrite all your URLs to include a suffix "-1" or some other number. Within the URL Rewrites, Magento differentiates between System URLs and Custom URLs. If the System URLs are broken like this, you should not fix this by adding new Custom URLs.
Instead, open up phpMyAdmin, create a backup of your Magento database, and flush the Magento table core_url_rewrite (so that it becomes totally empty). Immediately afterwards, refresh the Catalog Url Rewrites under Index Management. This will regenerate all System URLs.