You can set many types of 301 redirection from .htaccess file. We have mentioned about olddomain to newdomain 301 redirection in this topic.

For example, if you have a website and wish to permanently forward users to when they browse on their browsers.

Add following lines on the .htaccess file :

RewriteEngine on
RewriteCond %{http_host} ^ [NC,OR]
Rewritecond %{http_host} ^ [nc]
RewriteRule ^(.*)$$1 [r=301,nc]