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

301 redirect with .htaccess file

301 redirect with .htaccess is a permanent redirect on the homepage, which is part of the HTTP protocol and is used when the content of a website has been permanently moved to a new address. When a user or search engine tries to open the old address, a 301 redirect automatically redirects them to the new address. 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

RewriteRule 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.

301 redirect with .htaccess is a permanent redirect on the homepage, which is part of the HTTP protocol and is used when the content of a website has been permanently moved to a new address.
Screenshot

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.

301 redirect with .htaccess - 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.fi/
# Expired link redirection
Redirect 301 /expired-link https://www.redirectsto.fi/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\.fi$ [NC]
RewriteRule ^$ https://www.redirectsto.com/en/ [R=301,L]

https://redirecteddomain.fi/ → https://www.redirectsto.com/en/
https://redirecteddomain.fi/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\.fi$ [NC]
RewriteRule ^(.*)$ https://www.redirectsto.com%{REQUEST_URI} [R=301,L]

https://redirecteddomain.fi/ → https://www.redirectsto.com/
https://redirecteddomain.fi/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\.fi$ [NC]
RewriteRule ^(.*)$ https://www.redirectsto.com/ [R=301,L]

https://redirecteddomain.fi/ → https://www.redirectsto.com/
https://redirecteddomain.fi/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 18. Dec 2024
Was this article helpful?

Related Articles