1. Home
  2. Technical
  3. 301 redirect with .htaccess file

301 redirect with .htaccess file

.htaccess file

It is possible to redirect visitors to the website using the .htaccess file, using 301 redirection. A file with this name must be created in the home directory of the website you want to redirect. If you want to redirect to the virtual server’s main domain, add the file to a folder called /htdocs.

Attention!

If you don’t have a web-hosting service at Zone, it is possible to redirect the domain using a URL records.
Instructions for doing this can be found here

Instructions

The easiest way to manage a file is via the WebFTP web-based FTP application in My Zone.

After logging in to the control panel with your ZoneID account, you can manage your web server files by choosing Files from the overview page.

In the new window choose the /htdocs folder and add a file called .htaccess (preceded by a dot).

Then choose + (plus sign) and New File from the bottom menu.

To edit the contents of the file, left-click on the file and select Edit.

Copy the content of the appropriate rule to the file:

1. Simple redirection

# Main domain redirection 
Redirect 301 / https://www.redirectsto.eu/
# Expired link redirection
Redirect 301 /expired-link https://www.redirectsto.eu/new-website

2. Forwarding of incoming requests to the main domain only. The link structure is not included in the targeting.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?redirecteddomain\.eu$ [NC]
RewriteRule ^$ https://www.redirectsto.com/en/ [R=301,L]

https://redirecteddomain.eu/ → https://www.redirectsto.com/en/
https://redirecteddomain.eu/subpage → not redirected

3. Redirecting queries to the main domain, including subdomains. The link structure will be included in the redirection.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?redirecteddomain\.eu$ [NC]
RewriteRule ^(.*)$ https://www.redirectsto.com%{REQUEST_URI} [R=301,L]

https://redirecteddomain.eu/ → https://www.redirectsto.com/
https://redirecteddomain.eu/subpage → https://www.redirectsto.com/subpage

4. Forwarding all queries to a specific address. The link structure is not included in the redirection.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?redirecteddomain\.eu$ [NC]
RewriteRule ^(.*)$ https://www.redirectsto.com/ [R=301,L]

https://redirecteddomain.eu/ → https://www.redirectsto.com/
https://redirecteddomain.eu/subpage → https://www.redirectsto.com/

In the “redirecteddomain” line, replace the domain that the visitor enters in the address bar.

In the “redirectsto” line, replace the information with the address you want to redirect visitors to.

Additional information!

Other .htaccess file rules can be found here

Updated on 17. Dec 2024
Was this article helpful?

Related Articles