Cyclone3 Skin

Rewrite.conf

From Cyclone3 Wiki

This configuration file specifies the rewrite rules for prettyfied links - as in www.example.tld/en/article/245_this-is-my-first-article instead of www.example.tld/?type=article_view&ID_entity=245&name_url=this-is-my-first-article.

It looks like this:

article/{ID_entity;regexp="\d+"}-{name_url}|type="article";ID_entity;name_url;

{a210_path}|a210_path;
|type="default";
|;

The rules are, well, basically simple, you just need to know how it works. It works on both sides - if you type in a textual URI in the browser, Cyclone3 can translate it into a set of parameters and vice versa, if you create a link in Cyclone3 with various parameters, it will be rewritten to a nice textual URI on the output.

One line = one rule. The rules are processed in their order, first one that suits, finishes the process. Strings on the left side, captured by {} are parameters, everything else is just plain text. Let's get the first line for an example, left (frontend) side first:

article/{ID_entity;regexp="\d+"}-{name_url}
  • after the first slash (not needed in the rule) the article string just as typed in the conf
  • another slash
  • an ID_entity, consisting of numbers only (see the regexp?)
  • dash
  • name, mostly in an url-rewritten form (ascii, no spaces, ...)

Now, if we've got a link that says www.example.tld/article/245_this-is-my-first-article it suits already the first config rule, and gets processed, left side first:

  • (ignoring article, as it's not captured)
  • (slash ignored again)
  • ID_entity=245 (the position fits, captured value is a number)
  • (ignored dash)
  • name=this-is-my-first-article

and the right side follows:

  • type=article (hardtyped, doesn't need to be the same value as in the left side's article string, you can specify other strings for different languages on a multilanguage service, while leaving the type name on the right side the same)

So now we know, that article type is being requested and we're sending it the ID_entity and name_url parameters. Without rewrite, the link would externally look like this: ?type=article&ID_entity=245&name=this-is-my-first-article

From the other side - if we internally create a link:

 <a href="?|?type=article&ID_entity=245&name_url=this-is-my-first-article">
    This is my first article
  </a>

it gets rewrited from the right side:

  • we've got a type specification, and it says article, this fits
  • we've got an ID_entity
  • we've got also a name_url

The whole right side is fine, so the system just takes the left side template, and replaces the captured items with the right parameters' values, so we again come back to: www.example.tld/article/245_this-is-my-first-article