How Do I Rewrite URL Modules For Scripting?

Our shared servers come with a URL Rewrite capability on both the Linux and Windows based plans.

Rewrite rules define the logic used to analyze requested URLs and map them to new ones when the request URL matches a defined rule.

Linux Servers

On Linux (Standard) plans you have access to Mod_Rewrite. Rules are placed into a file called .htaccess which can be opened or created with any text editor. For more information on Mod_rewrite, see the article here.

Below is an example of a Rule which can be used to force the www's onto anyone visiting your website, which can be handy for SEO and SSL certificates.

  RewriteEngine on
  RewriteCond %{HTTP_HOST} !^www.yourdomain\.com\.au$
  RewriteRule ^(.*)$$1 [R=301]

Windows Server

On Windows plans you have access to Microsoft URL Rewrite Module 2.0.

The rules are stored either in the ApplicationHost.config file or in Web.config files and is typically located in your document root, e.g. httpdocs

Note: We STRONGLY recommend backing up your web.config file before editing it. If you do mangle it, we can restore it from system backups but this many incur a fee and could result in your website being inaccessible until the backup can be restored for you.

For more details on creating rules, see this article here.

Here is an example of the standard redwrite rule used by wordpress in Microsoft URL rewrite module format;

Open the Web.config file that is located in the same directory where the WordPress files are installed, and paste the following XML section into the system.webServer element:

<rulename="Main Rule"stopProcessing="true">