ComputersProgramming

How to make CNC-links: step-by-step instruction

The world of the Internet is rapidly developing and conquering all new peaks. Millions of sites, services and services are happy to receive another user on their pages. Created a huge number of addresses that are generated automatically. And it is not always convenient to read and remember them. In addition, a meaningless set of characters is poorly ranked by search engines. As a result, it became necessary to introduce the implementation of the code in such a way that it could appear in a more convenient and pleasant looking user's eye.

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

What is CNC-links?

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

The following address might look like this: http://example.com/products/new/boat. Here it is clear that we are talking about products, and the new, and specifically - about the boat. This is the human-understandable URL. It is much better indexed by search engines and is shown in the issuance above the rest. A person who visits the site, will be able to understand that he went to the right section.

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

To implement transliteration and conversion to human-purpose URLs, special tools are used. They are available, usually in content management systems - CMS. Creating CNC-links occurs in them automatically, based on the name of the product, article or blog, as well as the section in which it is located. As a result, when creating a new record, adding a product, a human-understandable URL is formed, which is well perceived by both people and machines.

How to make CNC references in popular CMS

CMS - management system, content, which in a convenient and simple interface allows in a short time to create a full-fledged website. Functionality expands due to the large number of ready-made templates, modules and plug-ins. This allows a person far from programming languages PHP, JavaScript, HTML and related ones, to quickly create their own website or blog.

Virtually all content management systems have an excellent set of tools in the form of plug-ins for creating CNC. It is worthwhile to consider in more detail the most common of them.

  • WordPress is the most popular, according to statistics, content management system. It is installed on most known blogs and websites. Famous for its ease of development and installation.
  • Joomla - popular less, but still actively used among developers. It has good functionality, a choice of components, plug-ins and modules.
  • OpenCart - a separate project for creating online stores. Internally it resembles any CMS, but is "sharpened" for solving a narrow range of problems.

CNC links in WordPress - ease of implementation

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

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

First you need to find it and download it. Do it better with the official WordPress site. So you can avoid the probability of getting into the plug-in malicious code or ad code.

  • After downloading the archive, you need to unpack it.
  • Then you need to move this folder to the wp-content -> plugins section. This is done, usually with the help of any available FTP manager.
  • Now you need to log in to the admin panel of WordPress, entering your login 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 turned on.

Next, you need to configure the structure of the links.

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

In addition to Cyr-To-Lat, you can use the analogs that are on the official site. For example, such - WP Translitera, ACF: Rus-To-Lat, Rus-To-Lat Advanced. The installation of these plugins is similar, so it does not make sense to dwell on them separately.

CNC in Joomla, several options for creating

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

Joomla initially has built-in functionality for creating human-readable URLs. The CNC links in Joomla 3 can be enabled on the general settings page in the "SEO Settings" section. The item "Enable SEF (CNC)" must be set to "Yes". In this way, the links will be converted to a more understandable form.

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

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

Aliases in Unicode - this item carries the transliteration of the material name into the Latin alphabet. This is to ensure that instead of Russian letters or other symbols, something awkward and unreadable is displayed.

Alternative components for Joomla

You can also implement the CNC reference 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 site.

In its functionality, in addition to the conversion of URLs to the CNC, there is a set for generating metadata, search engines, keywords, and managing duplicate pages. It is worth noting the available support for the UTF-8 encoding and the setting of page 404 at its discretion.

In Joomla 3 there are three possible ways of installation: by downloading directly from the computer, from the site directory and by passing a link to it.

For the first version, the file will have to be downloaded. Then select the "CMS Administrative Panel" in the "Extensions" menu and go to "Extension Manager". With 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. It is enough just to copy the link to JoomSEF and specify it in the "Install from URL" field on the same tab. The system will check its availability and, if all the parameters are met, it will install.

It is worth noting that for the full work of the add-on, it is necessary that the items "Enable SEF", "URL redirection" and "Add suffix to URL" in the SEO settings have been translated to the "Yes" position.

The installed component will immediately enter the system in the active mode and begin its work. Namely, it converts all available references into a more aesthetic appearance.

JoomSEF has many options and options. With their help, you can very thinly bring all the links of the site to almost any required kind.

JBZoo and humanobject url

The JBZoo component is a versatile and powerful tool for creating online stores, directories, blogs and simple business cards based on the Joomla content management system.

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

Sometimes the standard SEF settings do not reach their components to perform the conversion. Therefore, to create CNC-links in JBZoo it is recommended to use the sh404SEF component. This product is free and is a good tool for creating links 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 that was downloaded previously.

OpenCart and CNC settings

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 in OpenCart 2 can be formed through manual configuration or with the help of separate modules.

You can start the CNC setup 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 .htaccess.txt file should be in the root directory. Since it does not have any effect on the system with the extension txt, 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 the CNC on the "Server" tab.
  • All changes need to be saved.
  • Now all the links should be transformed.

Sometimes, for some reason, many addresses still do not change and remain incomprehensible. To implement this task, you can use the SeoPro component. However, before installing it you will first have to implement OCMOD Multiline Fix. To do this, you must manually change the code of 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.

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, we need to find the condition:

  • If (! $ Limit) {
  • $ Limit = -1;
  • }

And after it add:

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

You must save these files after the change.

Then you need to install the SeoPro module itself. The downloaded archive should be unpacked on the server. Then execute a couple queries in 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 file index.php. 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 associated with the settings inside the admin area. In the menu it is necessary to find "Modules", go to "Modifiers" and click on updates. Being here, you need to go to the "Modules" list and install SeoPro in it. Then, click on the "Edit" button to go into it and save it. After all the manipulations, everything should work, if not, then you should try to reinstall the module again. Or ask specialized forums for help.

Implementation of the CNC functional in the PHP language

Most sites on the web are written in PHP. It is powerful enough, convenient and easy to learn. His work is invisible to the user, since the processing of the PHP code is on the server side and the browser is sending an already prepared HTML page, understandable to him.

You can see the implementation of the CNC-links in PHP on a small example of the code. However, to bring the address lines in real multi-page projects to a human-understandable form, you have to tinker.

Any site starts with index.php. Including and generates an appeal to other pages of the site. But first you need to change the configuration file htaccess a little. It should specify or uncomment several directives, as shown in the photo.

The first line allows you to convert the URL using the server. The second sets the base address. The next two lines perform checks for the presence of a file and folder. The latter passes control to index.php, if lines 3 and 4 are implemented without errors.

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

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

  • If (preg_match ('/([^a-zA-Z0-9\.\/\-\_\#])/', $ result)) {header ('HTTP / 1.0 404 Not Found'); Echo 'Invalid characters in the URL'; Exit; }

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

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

Here, an array $ array_url is declared, in which by 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 request was made not to a specific page, but to a domain. Therefore, you need to send id = 1 in response. Also at this point is meant a query to the project database that finds out if there is a value in the variable $ sef_value in the field SEF. If nothing is found, send the user a page 404. Finally, the address of the resulting code is processed and the corresponding materials or elements are issued.

Pros and cons of using CNC

The advantages of using human-looking URLs can be listed in this way:

  • The link visually looks more aesthetic, rather than a set of incomprehensible characters, especially on unfamiliar sites;
  • Remembering the address is much easier;
  • The entire path and structure of the site becomes understandable;
  • 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 violated;
  • Improved navigation on the site;
  • SEO optimization is significantly improved and search engines better index such a site.

The disadvantages are much less. And the most important of them is the setting. It is not always possible to bring the addresses of pages to the human kind 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 concerns sites with a large attendance. Due to the formation of links to the "fly", the load on the site is increased. But as the cost of network equipment is steadily declining, few people consider such costs for server resources. In general, the advantages far outweigh the disadvantages, so despite the complex implementation of human-understandable URLs, they are worth using.

Conclusion

The article considers which references are CNC, and which are not. The most simple and quick solutions to the problem were described in detail. And also some of the most accessible variants of 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, the bundle of CMS and CNC should be used as the most effective alternative to manual development.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.delachieve.com. Theme powered by WordPress.