Search

Suggested keywords:
  • Java
  • Docker
  • Git
  • React
  • NextJs
  • Spring boot
  • Laravel

How to create SEO friendly url

  • Share this:
post-title
SEO friendly URL is recommended for any website which wants to be indexed and wants its presence in search results. Searchengine mostly index the static URL. It will avoid the URL which has lot of query strings. Almost all websites generate content dynamically then how could the URL be static. That is the job of the programmer.

Another reason of using SEO friendly URL is more readability or visibility. It is easy to remember, easy to bookmark. Consider an example of a blog, which delivers article based on request. When user clicks the link, complete content of the article will be displayed. The URL could be something similar to below http://blog.com/article/101/hello-world Let understand the URL,
blog.com - Name of the site
article - The category of the blog. Blog may have many categories like News, Comments etc.
101 - It the database primary key identifier of the article.
hello-world - short description to represent the article.
Most of the websites follow similar kind of technique. Each component in the URL will have some information like what section and subsection the content belongs to. URL should have unique identifier to retrieve the content from the data store. In this example it is primary key in the database.

There are some tools available to achieve it. Developer could use mod_rewrite kind of module to rewrite or transform the dynamic URL to static URL. mod_rewrite is for Apache, similar kind of module is available for other web servers. Actual: http://blog.com?section=article&id=101
After rewrite: http://blog.com/article/101/hello-world
Most of the web framework provides an option to call corresponding handler based on request. Java Struts2 framework has similar kind of functionality. Another better option to control programatically.

Struts.xml will have below information. When there is any request for article, the method viewArticle will be invoked. articleID and articleName are member variables of the class articleAction. On request, the framework will break the URL components and set the member variables and invoke the action method. < action name="article/*" class="com.company.articleAction" method="viewArticle" >
< param name="articleID">{1}</param>
< param name="articleName">{2}</param>
< result>/article.jsp</result>
</action>
Most of the framework do provide similar kind of functionality. This is the easiest way to achieve the SEO friendly URL.

Editorial Team

About author
This article is published by our editorial team.