User-friendly URL and its settings

<< Click to Display Table of Contents >>

Navigation:  Work With The Engine >

User-friendly URL and its settings

DataLife Engine uses SEO-friendly URLs (human-readable URLs) for displaying news, which allows the article title or any other text to be added directly into the browser’s URL. This improves site indexing in search engines, which will bring more visitors from search results.

To use SEO-friendly URLs, your server must have the mod_rewrite module enabled if you are using Apache as the main server for PHP. If your server does not support this, you can disable this feature in the script settings.

 

For Apache:

 

If you are using Apache as the PHP server, the root directory of your site must contain a .htaccess file with the following content (it comes with the DLE distribution):

 

DirectoryIndex index.php

 

<IfModule mod_rewrite.c>

 RewriteEngine On

 

 RewriteCond %{REQUEST_FILENAME} !-f

 RewriteRule \.(jpg|jpeg|gif|ico|png|svg|webp|avif|js|css|mp3|ogg|mp4|mkv|avi|zip|rar|woff|woff2)(\?|$) - [L,NC,R=404]

 

 RewriteRule ^sitemap.xml$ uploads/sitemap.xml [L]

 RewriteRule ^google_news.xml$ uploads/google_news.xml [L]

 RewriteRule ^static_pages.xml$ uploads/static_pages.xml [L]

 RewriteRule ^category_pages.xml$ uploads/category_pages.xml [L]

 RewriteRule ^tags_pages.xml$ uploads/tags_pages.xml [L]

 RewriteRule ^news_pages(\d*?).xml$ uploads/news_pages$1.xml [L]

 

 RewriteCond %{REQUEST_FILENAME} !-f

 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteRule . index.php [L]

</IfModule>

 

For Nginx:

 

If you are using Nginx as the PHP server, the configuration of your domain must contain the following directives inside the location section:

 

location / {

 

   location ~ ^/backup/ {

       deny all;

       return 403;

   }

 

   location ~ ^/engine/ {

       deny all;

       return 403;

   }

 

   location ~ ^/public/.*\.ph(p\d*|tml)$ {

       deny all;

       return 403;

   }

 

   location ~ ^/language/ {

       deny all;

       return 403;

   }

 

   location ~ ^/templates/.*\.(ph(p\d*|tml)|tpl)$ {

      deny all;

      return 403;

   }

 

   location ~ ^/uploads/.*\.ph(p\d*|tml)$ {

       deny all;

       return 403;

   }

 

   location ~ ^/uploads/files/.*\.(avi|divx|mp3|ogg|flac|aac|mp4|wmv|m4v|m4a|mov|mkv|webm|m3u8)$ {

       allow all;

   }

 

   location ~ ^/uploads/files/ {

       deny all;

       return 403;

   }

 

   rewrite "^/sitemap.xml$" /uploads/sitemap.xml last;

   rewrite "^/google_news.xml$" /uploads/google_news.xml last;

   rewrite "^/static_pages.xml$" /uploads/static_pages.xml last;

   rewrite "^/category_pages.xml$" /uploads/category_pages.xml last;

   rewrite "^/tags_pages.xml$" /uploads/tags_pages.xml last;

   rewrite "^/news_pages(\d*?).xml$" /uploads/news_pages$1.xml last;

   

# your remaining domain configuration code

   

   try_files $uri $uri/ /index.php?$args;

}

 

Where instead of the placeholder comments, you should include your additional domain settings, PHP handlers, and other configurations. For Nginx configuration, we recommend contacting your system administrator or your hosting provider’s support team.

 

Customizing link structure and rules:

You can modify and configure the appearance of SEO-friendly URLs in the relevant section of the admin panel. However, we do not recommend changing the link structure for inexperienced users. For them, it’s best to choose one of the three pre-configured options in the script settings.

 

If you decide to create your own link structure or add custom rules, you must follow a few rules. By default, the search pattern syntax uses placeholders, where for example {foo} means a match assigned to the variable foo, and the match itself corresponds to the regular expression [^/]+ (any sequence of characters up to the first slash).To customize the pattern, you can specify your own rule, e.g. {bar:[0-9]+}. Some examples:

 

/user/{id:\d+}/ matches /user/42 but not /user/xyz

/user/{name}/ matches /user/foobar/ but not /user/foo/bar

/user/{name:.+}/ matches /user/foo/bar entirely as-is

 

The matched values are assigned to the specified names. In these examples, the extracted values can be passed into the real link using the {id} and {name} tags. Accordingly, the script will receive values in $_GET['id'] and $_GET['name'].

 

Custom parameters for SEO-friendly URL patterns cannot use capturing groups, since the placeholders themselves are already groups. For example, {lang:(en|de)} cannot be used, because () is a capturing group. Instead, you should use {lang:en|de} or {lang:(?:en|de)}.

 

Important: When changing DLE’s default SEO rules, you must pass only the variables that DLE can process and understand. For example, to display a full news article, DLE recognizes the link /index.php?newsid=123, where the variable newsid contains a numeric value. No matter how you change the SEO link pattern, you must ensure that the real link passes the newsid variable with a numeric value.