Tribiq CMS

Switch to equivalent content in:

mod_rewrite (Apache URL Rewriting Engine)

If you wish to enable mod_rewrite, then you first need to activate the setting in Tribiq CMS. This enables Tribiq CMS to generate hyperlinks suitable for working with SEO URLs.

  1. Make sure that the Site Settings for mod_rewrite are enabled. Choose an appropriate extension (.html for example)
  2. Paste the following into your .htaccess file

RewriteEngine On
RewriteRule ^/(([A-Za-z0-9_-]*/)*)$ /$1index.php [QSA]
RewriteRule ^/(([A-Za-z0-9_-]*/)*)([A-Za-z0-9_-]+)\.html$ /$1index.php?id=$3 [L]

More advanced users may prefer to use a more extensive version:

RewriteEngine On
RewriteRule ^/(([A-Za-z0-9_-]*/)*)$ /$1index.php [QSA]
RewriteRule ^/(([A-Za-z0-9_\.-]*/)*)([A-Za-z0-9_-]+)\.html$ /$1index.php?id=$3 [L]
RewriteCond %{HTTP_COOKIE} !(COOKIE_ADMIN_MODE=true)
RewriteCond %{QUERY_STRING} ^(id|cID)=[^0-9][^&]+$
RewriteCond %0 [^=]+$
RewriteRule .* %0.html? [R=301,L]

Below is a break down of the mod_rewrite statements. You may wish to customize the statements after understanding how they operate.


RewriteEngine On
This switches the rewrite engine on, without it, the following rules
would do nothing.

RewriteRule ^/$ /index.php [QSA]
Rewrite all requests with no path specified to index.php, "[QSA]" says
to append the query string.

RewriteRule ^/([A-Za-z0-9_-]+)\.html$ /index.php?id=$1 [L]
Rewrite a path ending in "<something>.html" to
"index.php?id=<something>"
The "[L]" means that if a url matches this rule, do not apply any of the
following rules to it.

 RewriteCond %{HTTP_COOKIE} !(COOKIE_ADMIN_MODE=true)
If the current request does not have a cookie called "COOKIE_ADMIN_MODE"
with a value of "true"

RewriteCond %{QUERY_STRING} ^(id|cID)=[^0-9][^&]+$
If the current request has a query string starting with "id=" or "cID="
and the part following that is not a number and not empty.

RewriteCond %0 [^=]+$
Take the match from the condition above and match the part of it between
the "=" and the end.

RewriteRule .* %0.html? [R=301,L]
Rewrite any path (but this rule is only applied if the above conditions
are true) to the match from the rule above with ".html" appended.
The "?" clears the query string.
The "R=301" means make this an external redirect (send a redirect header
to the browser so that it changes the url pointed to) and indicate that
the content has permanently moved.
 

Top of Page