---
title: "301 redirect with .htaccess file"
canonical_url: "https://www.zone.lv/help/kb/301-redirect-with-htaccess-file/"
post_type: "ht_kb"
published: "2017-09-01T01:33:49+00:00"
modified: "2024-12-16T07:12:46+00:00"
language: "en"
author: "Gustav"
taxonomies:
  ht_kb_category:
    - name: "Technical"
      url: "https://www.zone.lv/help/kb-categories/technical-en/"
  ht_kb_tag:
    - name: "htaccess"
      url: "https://www.zone.lv/help/kb-tags/htaccess/"
    - name: "redirect"
      url: "https://www.zone.lv/help/kb-tags/redirect/"
    - name: "tehniline"
      url: "https://www.zone.lv/help/kb-tags/tehniline-eng/"
    - name: "URL"
      url: "https://www.zone.lv/help/kb-tags/url-en/"
    - name: "web"
      url: "https://www.zone.lv/help/kb-tags/web-eng/"
---

# 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 `<a href="https://www.zone.lv/help/en/kb/redirecting-domain-using-url-records/">here</a>`

## Instructions

The easiest way to manage a file is via the WebFTP web-based FTP application in [`My Zone`](https://www.zone.lv/en/zwebadmin/).

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.

[![](https://www.zone.lv/static/sites/5/ENG-301-redirection-1024x519.png)](https://www.zone.lv/help/en/kb/301-redirect-with-htaccess-file/eng-301-redirection/)

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

[![](https://www.zone.lv/static/sites/5/WEBFTP1.png)](https://www.zone.lv/static/sites/5/WEBFTP1.png)Then choose `+` (plus sign) and `New File` from the bottom menu.

[![](https://www.zone.lv/static/sites/5/WEBFTP2.png)](https://www.zone.lv/static/sites/5/WEBFTP2.png)To edit the contents of the file, left-click on the file and select `Edit`.

[![](https://www.zone.lv/static/sites/5/WEBFTP3.png)](https://www.zone.lv/static/sites/5/WEBFTP3.png)
Copy the content of the appropriate rule to the file:

**1. Simple redirection**

```
# Main domain redirection
Redirect 301 / https://www.redirectsto.ee/
```

```
# Expired link redirection
Redirect 301 /expired-link https://www.redirectsto.ee/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.ee/en/ [R=301,L]

```

https://redirecteddomain.eu/ → https://www.redirectsto.ee/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.ee/ [R=301,L]
```

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

 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](https://www.zone.lv/help/en/kb/examples-of-htaccess-rewrite-rules/)
