#301 Permanent redirect for sub-folder to main domain
RewriteEngine On
RedirectMatch permanent ^/subfolder/$ http://www.yourdomain.com/
#302 Temp redirect
RewriteEngin On
RedirectMatch 302 ^/subfolder/$ http://www.yourdomain.com/
#Redirect from http://www.yourdomain.com/subfolder/(post-url) to http://www.yourdomain.com/(post-url)
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.yourdomain.com
RewriteRule ^subfolder/(.*)$ http://www.yourdoamin.com/$1 [L,R=301]
#Redirect from subdomain’s subdirectory (sub.yourdomain.com/subfolder/(post-url) to http://www.mysample.com/(post-url)
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub.yourdomain.com
RewriteRule ^subfolder/(.*)$ http://www.yourdomain.com/$1 [L,R=301]
#Direct root domain to sub-folder index file
DirectoryIndex welcome/index.html
#Redirect old domain to new domain with exact same URL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
#Redirect old sub-directory url to specific new url
RedirectMatch 301 ^/sub1(.*)$ https://yourdomain.com/new-url.html
#Multiple sub-directories
RedirectMatch 301 ^/sub1/sub2/sub3(.*)$ https://yourdomain.com/new-url.html
#Redirect old file path to new file path
Redirect /v1/en/store-locator.html https://www.newlink.com/en/store-locator.html
#This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/