.htaccess (mod_rewrite)

The .htaccess file allows customised configuration settings to be applied to a specific directory (and any subdirectories thereof) on a Linux webserver.

The .htaccess file described in this article relates to Linux servers only, and should not be confused with the file of the same name created by FrontPage Extensions on a Windows server.

For general rules, place the .htaccess file in the /htdocs folder and for any rules specific to a sub-directory under the directory itself e.g. /htdocs/subfolder.

The .htaccess file will allow changes to the following configurations:


mod_rewrite allows you to manipulate URL's to make them more user and search engine friendly. An example of how mod_rewite can be used is to direct all requests to a non-www version of a URL to it's www counterpart. For example, requests to ralphsdomainname.com/test/ would be directed to www.ralphsdomainname.com/test. The .htaccess code to achieve this would be:

RewriteBase /
RewriteCond %{HTTP_HOST} !^www.webnxi.com$ [NC]
RewriteRule ^(.*)$ http://www.webnxi.com/$1 [R=301,L]
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Can I use mod_rewrite on my Linux server?

mod_rewrite is enabled only on our Linux hosting servers. Many blogging, content...

Powered by WHMCompleteSolution