Creating and managing redirects with your site can be done with a .htaccess file, the .htaccess file allows you to add to the default server configuration and has many more features than just creating redirects. When creating or making changes to your .htaccess file it's important to double check your content as the smallest syntax error could cause your site not to load.
Create an empty text file using a text editor such as Notepad/Notepad++, and save it as htaccess.txt
one of the reasons to do this is because some operating systems and FTP applications are unable to read or view .htaccess files by default as they are seen as system or hiden files. Once uploaded to the server you can rename the file to .htaccess
.
Redirect Rules
-
301 (Permanent) Redirect: Point your entire site to a different URL on a permanent basis.
Redirect 301 / http://yourdomain.tld/
-
302 (Temporary) Redirect: Point your entire site to a different temporary URL
Redirect 302 / http://yourdomain.tld/
-
Redirect index.html to a specific subfolder
Redirect /index.html http://yourdomain.tld/new-subfolder/
-
Redirect an old file to a new file
Redirect /old-directory/oldfile.html http://yourdomain.tld/new-directory/newfile.html
or you can use file paths only
Redirect /old-directory/oldfile.html /new-directory/newfile.html
-
Redirect error messages
ErrorDocument 404 http://yourdomain.tld/