How to make CNC links: step by step instructions

The world of the Internet is rapidly developing and conquering new heights. Millions of sites, services, and services are happy to host the next user on their pages. A huge number of addresses have been created that are generated automatically. And it is not always convenient to read and remember them. In addition, a meaningless character set is poorly ranked by search engines. As a result of this, it became necessary to introduce the implementation of the code in such a way that it could appear in a more convenient and pleasant way for the user's eye.

Therefore, the term CNC links has appeared in the world of web development. What this is and how to implement it will be discussed in the article.

What are CNC links?

In general, CNC is a slang word meaning human-readable URL. URL - borrowing from the English URL, a uniform resource locator. Human-readable, in turn, means a set of characters in the address bar, which is convenient and easy to read. For example, the generated page address might look like this: http://example.com/index.php?page=name. It does not look very clear and does not show the structure of the site. There are signs that do not carry a semantic load and it is not clear what the page and name mean.

The following address may look like this: http://example.com/products/new/boat. It is clear here that we are talking about products, and new, and specifically - about the boat. This is human-readable url. It is much better indexed by search engines and is shown in the results above the rest. And the person who visited the site will be able to understand that he went to the right section.

cnc links

However, CNC links have some limitations. For example, you cannot use Russian characters in the address. They are replaced with a numerical value and a percent sign. Therefore, domestic developers use the transliteration of Russian words in the Latin alphabet. For example, oborudovanie or produkcia. Also, an automatically generated CNC link can increase the total length of the string.

To implement transliteration and conversion to human-readable urls, special means are used. They are available, as a rule, in content management systems - CMS. The creation of CNC links takes place automatically in them, based on the name of the product, article or blog, as well as the section in which it is posted. As a result, when creating a new record, adding a product, a human-readable URL is formed, which is well perceived by both people and machines.

cnc wordpress links

How to make CNC links in popular CMS

CMS - content management system, which in a convenient and simple interface allows you to quickly create a full site. The functionality is expanded due to the presence of a large number of ready-made templates, modules and plug-ins. This allows a person who is far from the programming languages ​​PHP, JavaScript, HTML and related ones to quickly create his own website or blog.

Almost all content management systems have an excellent set of tools in the form of plug-ins for creating CNC. It is worth considering in more detail the most common of them.

  • WordPress is the most popular, according to statistics, content management system. It is installed on most well-known blogs and sites. It is famous for its ease of development and installation.
  • Joomla - less popular, but still actively used among developers. It has good functionality, a choice of components, plugins and modules.
  • OpenCart is a separate project for creating online stores. It internally resembles any CMS, but is “imprisoned” for solving a narrow range of tasks.

WordPress CNC Links - Easy to Implement

WordPress is probably the easiest content management system. It can greatly simplify the creation of a website or blog from scratch in a short time.

Setting up the CNC in WordPress is simple and comes down to downloading and installing the Cyr-To-Lat plugin. It serves to convert Cyrillic strings to Latin.

how to make cnc links

First you need to find and download it. Do it better from the official WordPress site. This way you can avoid the possibility of malicious or adware code getting into the plugin.

  • After downloading the archive, you need to unzip it.
  • Then you need to move this folder to the wp-content -> plugins section. This is usually done using any available FTP manager.
  • Now you need to go to the WordPress admin panel by entering your username and password.
  • In the "Plugins" section, you need to find Cyr-To-Lat and activate it. The plugin is now installed on the system and enabled.

Next, you need to configure the link structure.

  • To do this, go to the "Options", and there go to the "Permalinks".
  • In the general settings, there are several templates by which you can build the appearance of the link. It is recommended to use the “Arbitrary” type, which allows you to configure everything as necessary. The simplest construction for such a template is /% category% /% postname% /. It means that the category will be displayed in the address bar, and then the name of the post.
  • And then Cyr-To-Lat will convert all this into Latin alphabet. As a result, you get a beautiful and understandable CNC link in WordPress.

In addition to Cyr-To-Lat, you can use analogues that are available on the official website. For example, such - WP Translitera, ACF: Rus-To-Lat, Rus-To-Lat Advanced. Installing these plugins is similar, so stopping at them separately does not make sense.

CNC in Joomla, several options for creating

Joomla is a slightly more sophisticated content management system. Just like WordPress has the ability to create sites and blogs in a short time. It has extensive functionality and flexibility. Next, you need to describe how to make CNC references in this CMS.

Joomla originally has built-in functionality for creating human-readable urls. You can enable CNC links in Joomla 3 on the general settings page in the SEO Settings section. The “Enable SEF (CNC)” item must be set to “Yes”. Thus, the links will be converted to a more understandable look.

jbzoo cnc link

Here you can additionally set url redirection by creating a CNC link in htaccess. This file acts as the configuration store for the Apache web server. In it, using regular expressions and the RewriteRule directive, you can change the conversion of a link to the desired URL. The main difference between this approach is flexibility. You can bring links to almost any kind.

The item "Add suffix to URL" puts the document extension at the end of the line. For example, html. This extension is of little interest to the average visitor to the site, so the option can be left in the "No" position.

creating cnc links

Aliases in Unicode - this item transliterates the name of the material into the Latin alphabet. This is necessary so that instead of Russian letters or other symbols something awkward and unreadable is not displayed.

Alternative components for Joomla

You can also implement a CNC link generator in Joomla using various components. For example, one of the most popular is JoomSEF. It is distributed free of charge and it is better to download it from the official Joomla website.

In its functional, in addition to converting URLs to CNC, there is a set for generating metadata, search engines, keywords, as well as managing duplicate pages. It is worth noting the existing support for UTF-8 encoding and customizing the 404 page as you wish.

In Joomla 3, there are three possible installation methods: downloading directly from a computer, from a site’s directory, and by transferring a link to it.

For the first option, you have to download the file. Then select in the menu of the CMS administrative panel in “Extensions” and go to the “Extension Manager”. Using the “Select File” button, you need to show the system the prepared archive and install it.

The second option is rarely used. But the third is the most convenient of them, since it does not require downloading. Just copy the link to JoomSEF and specify it in the "Install from URL" field on the tab of the same name. The system itself will check its availability and, if all the parameters match, it will install it.

It is worth noting that for the add-on to work fully, it is necessary that the “Enable SEF”, “URL redirection” and “Add suffix to URL” items in the SEO settings are translated to the “Yes” position.

The installed component will immediately be introduced into the system in active mode and begin its work. Namely, it converts all available links into a more aesthetic look.

JoomSEF has a large number of settings and options. With their help, you can very finely bring all the links on the site to almost any kind you need.

JBZoo and Humano Url

The JBZoo component is a universal and powerful tool for creating online stores, catalogs, blogs and simply business card sites based on the Joomla content management system.

To install JBZoo in Joomla, it must already have a Zoo add-on.

Sometimes the standard SEF settings do not reach their components in order to perform the conversion. Therefore, it is recommended that you use the sh404SEF component to create CNC links in JBZoo. This product is free and is a good tool for linking in JBZoo. A large number of settings, functions, support for various social networks and services.

Installation is done by copying the link to the archive, or by directly uploading the file to the server downloaded previously.

OpenCart and CNC setup

OpenCart is a platform without being tied to any content management system. That is, it functions separately. Its main focus is the convenient creation of online stores of varying degrees of complexity. Despite the fact that the product itself is free, many additions to it are distributed on a commercial basis. The latest stable version is 2.0.

cnc links opencart 2

CNC links in OpenCart 2 can be generated by manual configuration or by using separate modules.

You can start the CNC configuration in the first way by editing the htaccess configuration file of the Apache web server.

  • To do this, go to the site folder via FTP or the file manager in the administrative memory.
  • The root directory must contain the .htaccess.txt file. Since it has no effect on the system with the txt extension, the first thing to do is rename it to .htaccess. Now the web server will read its directives and execute them.
  • Now you need to go to the site settings and enable the use of CNC on the "Server" tab.
  • All changes must be saved.
  • Now all links should be transformed.

Sometimes, due to some reasons, many addresses still do not change and remain incomprehensible. To implement this task, you can use the SeoPro component. However, before installing it, you must first implement OCMOD Multiline Fix. To do this, manually change the code for one file. It is located at admin / controller / extension / modification.php. To edit it, it is recommended to use the Notepad ++ utility to avoid encoding problems.

links are cnc

You need to add only one line of code to the block after the $ limit variable. It looks like this:

  • $ quote = $ operation-> getElementsByTagName ('search') -> item (0) -> getAttribute ('quote');

Next, you need to find the condition:

  • if (! $ limit) {
  • $ limit = -1;
  • }

and after it add:

  • if ($ quote == 'true') {
  • $ search = preg_quote ($ search);
  • }

These files must be saved after the change.

Then you need to actually install the SeoPro module itself. The downloaded archive must be unpacked on the server. Then execute a couple of queries to the database using phpmyadmin:

  • ALTER TABLE `oc_product_to_category` ADD` main_category` tinyint (1) NOT NULL DEFAULT '0'; ALTER TABLE `oc_product_to_category` ADD INDEX` main_category` (`main_category`);

Now you need to fix the main index.php file. It is interested in the line:

  • $ controller-> addPreAction (new Action ('common / seo_url'));

which is replaced by:

  • if (! $ seo_type = $ config-> get ('config_seo_url_type')) {
  • $ seo_type = 'seo_url';
  • }
  • $ controller-> addPreAction (new Action ('common /'. $ seo_type));

Next, there is a set of procedures related to the settings inside the admin panel. In the menu you need to find “Modules”, go to “Modifiers” and click on updates. While here, you need to go to the "Modules" list and install SeoPro in it. Then, by pressing the "Edit" button, go into it and save. After all the manipulations, everything should work, if not, you should try reinstalling the module again. Or ask for help in specialized forums.

Implementation of CNC functionality in PHP

Most web sites are written in PHP. It is powerful enough, convenient and easy to learn. Its work is invisible to the user, since the processing of PHP code occurs on the server side and a ready-made HTML page is sent to the browser, which is clear to him.

htaccess cnc links

You can show the implementation of CNC references in PHP using a small code example. However, to bring the address lines in real multi-page projects to a human-readable form, you have to tinker.

Any site begins its work with the index.php file. Including generates an appeal to other pages of the site. But first you need to slightly modify the htaccess configuration file. It is necessary to indicate or comment out several directives, as shown in the photo.

cnc php links

The first line allows you to convert the URL using the server. The second - sets the base address. The following two lines check for the presence of a file and folder. The latter transfers control to index.php if the 3rd and 4th row are implemented without errors.

A table is needed to store the correspondence of the page id and its converted value. Therefore, it must be created. In particular, you can create a simple one to understand the process. It will contain two fields: SEF and page_id. SEF stores the name and is of type varchar. And page_id is the page number of type int.

Now it remains to fix the index.php file itself. This is just an example and in practice of a particular project everything can be a little different: $ result = $ _SERVER ['REQUEST_URI']. In this line, the requested URL is passed to the $ result variable.

  • if (preg_match ('/([â–ş-zA-Z0-9\.\/\-\_\#†)/', $ result)) {header ('HTTP / 1.0 404 Not Found'); echo 'Invalid characters in URL'; exit }

In this block, the presence of characters, numbers and some characters is checked. If there is anything other than those listed, then page 404 is displayed.

  • $ array_url = preg_split ('/(\/|\..*$)/', $ result, -1, PREG_SPLIT_NO_EMPTY);

An array $ array_url is declared here, in which, using the preg_split function, elements that have nothing superfluous in the CNC are placed.

  • if (! $ array_url) {$ ID_page = 1; } else {$ sef_value = $ array_url [0];

Here, the request is processed in the case when the call was made not to a specific page, but to a domain. Therefore, you need to send id = 1 in response. Also at this place is meant a query to the project database, which finds out if it contains a value from the $ sef_value variable in the SEF field. If nothing is found, send the page 404 to the user. At the end, the address obtained as a result of the code is processed and the corresponding materials or elements are returned.

Pros and cons of using CNC

The benefits of using human-readable urls can be listed as follows:

  • the link visually looks more aesthetic than a set of obscure characters, especially on unfamiliar sites;
  • remembering the address is much easier;
  • the whole path and structure of the site becomes clear;
  • GET parameters passed in the usual way use variables in the address bar, which is not in the CNC, which means that security is not compromised;
  • Improved site navigation
  • SEO optimization improves significantly and search engines better index such a site.

The disadvantages are much smaller. And the most significant of them is tuning. It is not always possible to bring the page addresses to a human-readable form by means of regular or third-party solutions. Sometimes you have to delve into the code and edit it yourself, which requires knowledge and time. The second drawback is not so significant and relates to sites with high traffic. Due to the formation of links on the fly, the load on the site increases. But since the cost of network equipment is steadily decreasing, few people consider such costs for server resources. In general, the advantages far outweigh the disadvantages, so despite the difficult implementation of human-readable urls, it’s worth using them.

Conclusion

The article examined which links are CNC and which are not. The most simple and quick solutions to the problem were detailed. As well as some of the most affordable options for complex approaches. In any case, the use of CMS in the development of the site significantly reduces labor and time costs when optimizing page addresses. Therefore, a combination of CMS and CNC should be used as the most effective alternative to manual development.


All Articles