Warning
This article is provided as a courtesy, meaning that Clouding.io will not configure rewrite rules for individual customer websites or provide syntax support, as reviewing it is the customer's responsibility.
This document explains how to create an .htaccess file to redirect a site or content. Remember that this will not redirect email for your domains.
Warning
As a configuration file, .htaccess is very powerful. Even the smallest syntax error (such as a missing space) can cause your website's content to display incorrectly or not at all. .htaccess files are hidden system files; please make sure your FTP client is configured to show hidden files. This is usually an option in the program's preferences / options.
Instructions
-
Create an empty text file with a text editor such as Notepad, and save it as htaccess.txt
Note
The reason you should save the file as htaccess.txt is that many operating systems and FTP applications cannot read or view .htaccess files by default. Once uploaded to the server, you should rename the file to .htaccess.
-
Edit the file's contents. You can review the following examples:
- Redirect a web page to another URL, such as dominio.net redirected to dominio.com:
Redirect 301 / http://dominio.com/
(This allows you to redirect your entire website to any other domain) - Redirect your index.html to a subfolder:
Redirect /index.html http://dominio.com/newdirectory/
(This allows you to redirect index.html to a subfolder) - Redirect an old file to a new file path:
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
(This allows you to redirect an old file to a new file path) - Redirect to a specific index page:
DirectoryIndex index.html
(This allows you to redirect to a specific index page)
- Redirect a web page to another URL, such as dominio.net redirected to dominio.com:
Tip
You can find the definitive guide to the Apache directives that can be used in .htaccess files at: http://httpd.apache.org/docs/mod/core.html.
More advanced URL changes with mod_rewrite:
If you need to make complex changes to how the URL is displayed, you can find information in our article 'Using rewrite rules in .htaccess'. You will be able to do things like add “www” to the beginning of the URL, redirect all requests to a subfolder while keeping the rest of the URL, etc…