Magento Expert Forum - Improve your Magento experience
How to rewrite URL in Magento
It is critically important for all the websites to have URLs friendly to serve SEO purpose. However it is not always easy for us to create those in Magento especially when you install a module. How can we tackle this problem as of a non-technical user? We provide 2 feasible solutions for URL Rewriting in Magento and create appropriate URLs as you want. You see it will not a big issue any longer.
Before we approach to the 2 solutions, we are showing an example to describe how a default URL is created and prerequisite knowledge to hatch some repairing. Eg. We created a module for Blog named Blog and its namespace is MGS with simple fields as
id \ title \ description
In the back-end, when we create a post we need to insert two fields, ie. Title and Description. ID of the post will be auto-generated. In order to display post details of the Blog we rely on router (declared in file config.xml, we declared blog), controller (we named index, so it will be file IndexControler.php in folder controllers), action (we called view, viewAction function in file IndexControler.php) and id of the post.
So, default URL of the post at front-end will look like this:
http://domain.com/blog/index/view/id/1 (1 is ID of the post)
As far as we can see this URL is totally not good for SEO, it should be rewritten to turn into a URL friendly. Back to the main objective, we proposed 2 methods to create URL friendly. And in either ways you will need to define URL you want or you will follow a common rule to create the URL (usually we will use the title of the post, convert all characters into normal style, replace empty space with -, eg. Title “How to rewrite url in Magento” will become “how-to-rewrite-url-in-magento.
In this article we will use URL definition approach, therefore, we will add one more field to the above database to save the URL.
id \ title \ description \ url
So, URL of the post will be filled out.
First technique to rewrite URL
Use URL rewrite function of Magento, you can get more details at Catalog-> URL Rewrite Management.
READ FULL LESSION : http://www.magesolution.com/blog/url-rewriting-magento/
View more threads in the same category: