Web Design Blog
.htaccess file | .htaccess file |
|
|
|
|
The Apache Web server provides a feature called .htaccess file, which provides commands to control a Web site. This file is simply a text file containing Apache directives. Those directives apply to the documents in the directory where the file is located, and to all subdirectories under it as well. Other .htaccess files in subdirectories may change or nullify the effects of those in parent directories. Here are some useful information: Redirect non-www to www version of siteRewriteEngine On RewriteCond %{HTTP_HOST} ^YourSite.com [nc] RewriteRule (.*) http://www.YourSite.com/$1 [R=301,L] Or the code below that you don't have to rewirte the domain: RewriteEngine On RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RedirectsYou can use .htaccess file to redirect any request for a specific page to a new page...
Redirect /OldDir/old.html http://site.com/NewDir/new.html
Redirect the missing file to index RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ http://%{HTTP_HOST}/ [R]Apache Module mod_rewrite reference |
| Next > |
|---|