Tutorials to guide your way

From our tutorials section you will find lots of useful content to help you use our services.


.htaccess files and rewrite

9.7.2018

There are many user friendly tools to create the desired rewrite rules. Here are some examples rewrite rules:

Example 1

RewriteEngine On RewriteRule ^([^/]*).html$ /index.php?page=$1 [L]

With this rule you can create from address /index.php?page=file a version which is much easier to remember in form /sivu.html

Server will still look in the index.php file for the content.

Example 2

RewriteEngine On RewriteCond %{HTTP_HOST} ^shellit.fi RewriteRule ^(.*)$ http://www.shellit.fi/$1 [R=permanent,L]

With this rule, you can forward all the users from http://shellit.fi to address http://www.shellit.fi

Example 3

RewriteEngine On RewriteCond %{HTTP_HOST} ^vanhadomain.fi$ [OR] RewriteCond %{HTTP_HOST} ^www.vanhadomain.fi$ RewriteRule (.*)$ http://www.uusidomain.fi/$1 [R=301,L]

With this rule you can forward olddomain.fi and www.olddomain.fi immediately to new domain in www.newdomain.fi

All the rewrite rules should be saved in .htaccess file. File needs to be in the folder where the site is located. For example this can be public_html or any other folder which is configured in subdomain settings.




Was this article helpful?



Related Articles