Htaccess redirections
- Individual file redirection
To redirect individual files, like example.com/oldfile.htm to newfile.htm you can use a 301 redirect like this:
Redirect 301 /oldfile.htm /newfile.htmTo redirect one specific file to another domain such as example.com/oldfile.htm to example.net/newfile.htm:
Redirect 301 /oldfile.htm http://example.net/newfile.htm- An domain to a new domain redirection
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301,NC]- Force www domain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]