Knowledge Essentials - 3Essentials Hosting

URLRewrite/mod_rewrite for Linux

Article ID: 1154

 Back to Search

In order to use Mod Rewrite for *nix based servers (WEB 5, WEB7, WEB9) You must find and edit your .htaccess file. 

**BACKUP THIS FILE BEFORE MAKING ANY CHANGES TO IT**

To turn mod rewrite on for apache, add the following line to your .htaccess file:

RewriteEngine on 

This will turn the Rewrite engine on for your domain.

An example of a rewrite rule would be the following:

This will direct the page 'test.html' to test.php.  The test.html will remain on the URL, but you will actually be visiting test.php:

 RewriteRule ^/?test\.html$ test.php [L]

This is a 301 Redirect (Permanent Redirect) that will redirect any request made to your domain to http://www.mydomain.com

Even if someone types in http://mydomain.com/TEXTGOESHERE.html, it will get forwarded to http://www.mydomain.com/TEXTGOESHERE.html

 RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

 More information can be found on apache's website on this:

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

 
Downloads Associated With This Article
No downloads are currently associated with this article.