The website should be designed to be transparent and easy to understand for both users and search engine robots. One of the elements that should be optimized are URLs. A short and simple URL is much easier to remember, helps to navigate and looks better, which increases credibility more than a long and incomprehensible link. Properly built URLs will help to avoid indexing problems. It affects the click-through rate and the probability of noticing it in SERP. Of course, it is not as visible as the page title, but inputting the correct key phrases in the link is just as important.
Table of Contents
First of all, let’s understand what URL actually is. The website URL is nothing more than what you see in the address bar of your web browser, for example:
https://boostsite.com/blog/what-is-lazy-loading/
URL consists of:
The acronym is an extension of the Uniform Resource Locator. This means a unified format for addressing information, data and services used on the Internet and in local networks. It also defines how the resource will be retrieved from the server. URL is a special case of URI, or Uniform Resource Identifier, which is used only to identify a resource, from web pages to files on disk. The URL, on the other hand, shows only the web address from which the file can be downloaded.
Friendly links consist of logical strings or refer to the parent category and indicate where on the page the user is at a given moment. So URLs structure can represent the hierarchy of pages on the website. Let’s use the following example:
Good URL structure
http://www.example-shop.com/phones/android/
Bad URL structure
http://www.example-shop.com/e9a2.aspx?id=14&ep
In a “good URL structure” example it is quite obvious that the user is browsing a category of phones that use the Android system. The “bad URL structure” example tells You nothing at all. There are several conditions to be met, to consider a URL an SEO friendly URL:
Friendly URLs have a positive effect on SEO, as this aspect is considered a ranking factor by Google. Properly placing keywords that will direct the user to the content of a given subpage, will increase the visibility of these phrases in the search results and increase the chance of getting converting traffic. Google bots will appreciate friendly URLs while indexing the website as well.
Aside from the pure SEO benefits the user can get a glimpse of the info what the page content is about prior to clicking the link. This can have a positive impact on user experience & engagement with Your brand – better recognition & design.
There are several ways to create a friendly link.
Most CMSes have some kind of URL control mechanisms already in place. The important thing is to use them properly, including all of the SEO rules mentioned above. As WordPress is by far the most popular content management system, here is the simple step-by-step guide to implementation of exemplary URL structure that will work well for SEO purposes:
Custom structure URL build schema will put all of the blog posts in https://boostsite.com/blog/ path and will be followed by post name.
At the very beginning, we should start by entering into the .htaccess file the configuration directive that runs the mod_rewrite module:
RewriteEngine on
At this point, we can start inserting rules that create a friendly version of our URL. Some introductory examples:
RewriteEngine on RewriteRule index.php$ index.html
The above code will make us go to domain.com/index.html after entering e.g. domain.com/index.php.
Why? RewriteRule is about rewriting the address. When we wrote above index.php$, it means that if after domain.com/ or domain.com/catalog/ there is index.php and nothing else. The $ sign is responsible for the end of respecting later, this will redirect us to domain.com/index.html.
The rule will work in this case, but in others, for example: domain.com/catalog/index.php?x=100 or domain.com/index.php?x=100, it will not work because index.php is followed by characters – in this case x = 100.
Now let’s move strictly to building a friendly version of the URL. Removal of .php, .html, .htm, or any other extensions can be done in the following way:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [R=301,L]
Short explanation: RewriteCond %{REQUEST_FILENAME} !-f and RewriteCond %{REQUEST_FILENAME} !-d checks that the address does not lead to a directory (-d) and that it leads to a file ending in .php (-f).
If the conditions are met, the rule will be executed to permanently replace a string with the suffix .php into a string with no extension.
Often, after creating a page and entering an address in the browser, e.g. domain.com/index.html, we will not be transferred to an address without an index, which would be advisable.
This can be done in a very simple way:
RewriteRule^index.(Php|html|htm)$/[R=301,L] RewriteRule^([a-z0-9 -_]+)/index.(Php|html|htm)$/$1/[R=301,L]
An explanation in this case I think is not necessary anymore, but for ordering – a short explanation: “If the address (after domain.com/ starts with a letter (or / i) digit and ends with / index. + Extension, redirect to this which starts with an address (before / index) and add the slash “/” to the end “.
To prevent a page from being available on two addresses (with and without a slash at the end), it would be a good idea to create a rule in .htaccess that will force the end of the slash to be added if it is not there.
RewriteRule^([a-z0-9 -_]+)$https://%{HTTP_HOST}/$1/[R=301]
Brief explanation: “If the address starts with a string that does not end with a slash ($ sign – no more respect for the rest) – redirect to https://domain.com/stringofcharacters/ (add slash at the end) with permanent carry.
RewriteRule^category/([a-z0-9 -_] +)/categories/article.php?name=$1[R=301]
The above code will make us have an available address in the form domain.com/category/stringofcharacters from an address in the form domain.com/categories/article.php?name=stringofcharacters thanks to the characters declared in parentheses being defined in code $ 1.
Similarly to this example, we can define further variables.
The parenthesis is the equivalent of a digit with a dollar sign, for example: (. *) (. *) Will be equivalent to $1 $2. Finally, a short example with two variables to illustrate the analogies of using “dollars”: address from domain.com/article.php?variable1=abc&variable2=cde to domain.com/article-abc-cde/:
RewriteRule^article-([a-z0-9-_] +)-([a-z0-9 -_]+)/$article.php?Variable1=$1&variable2=$2[R=301]
As you can see we have two parentheses on the left hand side which correspond to two “dollars” on the right hand side.
This is a quite important notice, especially for the websites that have already been indexed by Google. Rewriting the URL structure into an SEO friendly one may harm Your short term SEO if not done properly. Once Your website has been indexed, both old & new URL structures should be reflected in the 301 redirect matrix, to let the search engines know what has happened.
Remember that URLs are a very important part of Your online presence. Make sure that You will not change it too often. Make modifications only when it is absolutely necessary & prepare yourself thoroughly.
15+ years of experience in effective business & marketing management, often in both corporate & startup environments. Effective marketing manager & a digital marketing expert. Business-oriented, with proven skills to scale up sales & revenues with consideration of CAC vs LTV customer lifecycle management, product development & ROI / ROAS optimization.
SEO expert with over 10 years of experience in the industry. He has worked for many international companies known globally, creator of the Boostsite.com algorithms.
Tomasz Więckowski