---
title: Typical Redirects
description: "Comprehensive guide to common .htaccess redirects: domain, www, HTTPS, subdirectories, and page-specific rules for Apache, VestaCP, and ispmanager setups."
---

[Skip to content](https://help.ishosting.com/en/typical-redirects#main-content)

- [English](https://help.ishosting.com/en/typical-redirects)
- [Русский](https://help.ishosting.com/ru/typical-redirects)

English

Show submenu for translations

[![is\*hosting](https://help.ishosting.com/hubfs/Logo_Ishosting_mono-1.svg)](https://help.ishosting.com/en)

- [Blog](https://blog.ishosting.com/en)
- [Support](https://my.ishosting.com/en/tickets)

Open main navigation

Close main navigation

- [Blog](https://blog.ishosting.com/en)
- [Support](https://my.ishosting.com/en/tickets)
- - [English](https://help.ishosting.com/en/typical-redirects)
    - [Русский](https://help.ishosting.com/ru/typical-redirects)

  English
  
  Show submenu for translations
- [Go to ishosting.com](https://ishosting.com/)

[Go to ishosting.com](https://ishosting.com/)

 Hello. How can we help you?

- There are no suggestions because the search field is empty.

1. [Help Center](https://help.ishosting.com/en)
2. [Server Administration](https://help.ishosting.com/en/server-administration)
3. [Other](https://help.ishosting.com/en/server-administration#other)

# Typical Redirects

## This article provides a collection of commonly used .htaccess redirect rules for Apache-based VPS setups.

You can set up redirects using the site's .htaccess file. This article lists commonly used redirects. For their work, you must have:

- standard VPS + Apache with the mod\_rewrite module enabled,
- standard VPS with the VestaCP or ispmanager panel installed in automatic mode.

ATTENTION! The redirects described in the article are not suitable for OS Bitrix7.

In ispmanager, you can also use the [built-in panel tools for redirections](https://help.ishosting.com/en/redirects).

Redirects are set in the .htaccess file in the \<IfModule mod\_rewrite.c\> block: 

```
<IfModule mod_rewrite.c>Options +FollowSymLinksRewriteEngine on#Правила</IfModule>
```

The rules include:

**RewriteCond** - condition,

**RewriteRule** - the action to be performed when the condition is met.

#### Redirect to another domain

To redirect from www.domain-1.com to www.domain-2.com, enter:

```
RewriteEngine onRewriteCond %{HTTP_HOST} ^(www\.)? domain-1\.com$RewriteRule ^(.*)$ http://www.domain-2.com/$1 [R=301,L]
```

#### **Redirect from a domain without www to a domain with www**

To redirect from domain.test.com to www.domain.test.com, enter:

Option 1, for a specific domain

```
RewriteCond %{HTTP_HOST} ^domain\.test\.com$ [NC]RewriteRule ^(.*)$ http://www.domain.test.com/$1 [R=301,L]
```

Option 2, without specifying any specific domain

```
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
```

#### **Redirect from a domain with www to a domain without www**

To redirect from www.domain.test.com to domain.test.com, enter:

Option 1

```
RewriteCond %{HTTP_HOST} ^www\.domain\.test\.com$ [NC]RewriteRule ^(.*)$ http://domain.test.com/$1 [R=301,L]
```

Option 2

```
RewriteCond %{HTTP_HOST} !^domain\.test\.com$ [NC]RewriteRule ^(.*)$ http://domain.test.com/$1 [R=301,L]
```

#### Redirect to subdirectory

To redirect from the www.test.domain.com subdomain to the test subdirectory, enter:

```
RewriteBase /RewriteCond %{HTTP_HOST} ^test\.domain\.com$RewriteCond %{REQUEST_URI} !/test/RewriteRule ^(.*)$ /test/$1 [L]
```

#### Redirect from http to https

1\. To redirect from http://domain-1.com to https://domain-1.com, enter:

```
RewriteBase /RewriteCond %{HTTPS} !onRewriteCond %{HTTP_HOST} ^domain-1.com$RewriteRule ^(.*)$ https://domain-1.com/$1 [R=301,L]
```

2. For VPS with VestaCP panel enter:

```
RewriteCond %{SERVER_PORT} !^443$RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
```

3\. For VPS with ispmanager panel using Nginx enter:

```
RewriteBase /RewriteCond %{HTTPS} offRewriteCond %{HTTP:X-Forwarded-Proto} !httpsRewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
```

#### Redirect from http to https://www

 To redirect from http://test.com to https://www.test.com, enter:

```
RewriteBase /RewriteCond %{HTTPS} !onRewriteCond %{HTTP_HOST} ^ test.com$RewriteRule ^(.*)$ https://www.test.com /$1 [R=301,L]
```

To redirect from http://test.example.com to https://www.test.example.com, enter:

```
RewriteCond %{HTTP_HOST} ^test\.example\.com$ [NC]RewriteRule ^(.*)$ https://www.test.example.com/$1 [R=301,L]RewriteBase /RewriteCond %{HTTPS} !onRewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
```

#### **Redirect from http://www to https**

To redirect from http://www.test.example.com to https://test.example.com, enter:

```
RewriteCond %{HTTP_HOST} ^www\.test\.example\.com$ [NC]RewriteRule ^(.*)$ https://test.example.com/$1 [R=301,L]RewriteBase /RewriteCond %{HTTPS} !onRewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
```

#### Redirect from https to http:

```
RewriteBase /RewriteCond %{HTTPS} on [NC]RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
```

#### Redirect to http for one page

Option 1:

```
RewriteBase /RewriteCond %{HTTPS} on [NC]RewriteCond %{REQUEST_URI} ^/Required.directory.page$RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
```

Option 2:

```
RewriteBase /RewriteCond %{HTTPS} !onRewriteCond %{REQUEST_URI} !^/Required.directory.page$RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]RewriteCond %{HTTPS} on [NC]RewriteCond %{REQUEST_URI} ^/Required.directory.page$RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
```

For example, to disable the redirect to https for the bitrix/user/1c\_exchange.php page for the correct operation of data exchange with 1C, enter:

```
RewriteBase /RewriteCond %{HTTPS} !onRewriteCond %{REQUEST_URI} !^/bitrix/user/1c_exchange\.php$RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]RewriteCond %{HTTPS} on [NC]RewriteCond %{REQUEST_URI} ^/bitrix/user/1c_exchange\.php$RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
```

To disable redirect to https for the same page for the VestaCP panel, enter:

```
RewriteCond %{SERVER_PORT} !^443$RewriteCond %{REQUEST_URI} !^/bitrix/user/1c_exchange\.php$RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]  RewriteCond %{SERVER_PORT} ^443$RewriteCond %{REQUEST_URI} ^/bitrix/user/1c_exchange\.php$RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
```

#### Redirect to https for one page

```
RewriteBase /RewriteCond %{HTTPS} !onRewriteCond %{REQUEST_URI} ^/Required.directory.page$RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
```

If you have any questions, please create a [ticket](https://ishosting.com/en/support) to technical support.

- [Virtual Private Servers](https://help.ishosting.com/en/virtual-private-servers#main-content)

    - [Getting Started](https://help.ishosting.com/en/virtual-private-servers#getting-started)
    - [Working with VPS](https://help.ishosting.com/en/virtual-private-servers#working-with-vps)
    - [Software](https://help.ishosting.com/en/virtual-private-servers#software)
    - [Backup and Data Storage](https://help.ishosting.com/en/virtual-private-servers#backup-and-data-storage)
    - [Additional Services](https://help.ishosting.com/en/virtual-private-servers#additional-services)
    - [VPS Load](https://help.ishosting.com/en/virtual-private-servers#vps-load)
    - [Other Issues](https://help.ishosting.com/en/virtual-private-servers#other-issues)
- [Dedicated Servers](https://help.ishosting.com/en/dedicated-servers#main-content)

    - [Getting Started](https://help.ishosting.com/en/dedicated-servers#getting-started)
    - [Working with Dedicated Server](https://help.ishosting.com/en/dedicated-servers#working-with-dedicated-server)
    - [Additional Services](https://help.ishosting.com/en/dedicated-servers#additional-services)
    - [Other Issues](https://help.ishosting.com/en/dedicated-servers#other-issues)
- [Server Administration](https://help.ishosting.com/en/server-administration#main-content)

    - [API](https://help.ishosting.com/en/server-administration#api)
    - [Windows Instructions](https://help.ishosting.com/en/server-administration#windows-instructions)
    - [UNIX Instructions](https://help.ishosting.com/en/server-administration#unix-instructions)
    - [ispmanager](https://help.ishosting.com/en/server-administration#ispmanager)
    - [VestaCP](https://help.ishosting.com/en/server-administration#vestacp)
    - [DirectAdmin](https://help.ishosting.com/en/server-administration#directadmin)
    - [BitrixVM](https://help.ishosting.com/en/server-administration#bitrixvm)
    - [Security](https://help.ishosting.com/en/server-administration#security)
    - [DDoS Protection](https://help.ishosting.com/en/server-administration#ddos-protection)
    - [Working with Files](https://help.ishosting.com/en/server-administration#working-with-files)
    - [Databases](https://help.ishosting.com/en/server-administration#databases)
    - [PHP](https://help.ishosting.com/en/server-administration#php)
    - [Logs and Statistics](https://help.ishosting.com/en/server-administration#logs-and-statistics)
    - [Diagnostics and Troubleshooting](https://help.ishosting.com/en/server-administration#diagnostics-and-troubleshooting)
    - [HestiaCP](https://help.ishosting.com/en/server-administration#hestiacp)
    - [cPanel](https://help.ishosting.com/en/server-administration#cpanel)
    - [aaPanel](https://help.ishosting.com/en/server-administration#aapanel)
    - [FastPanel](https://help.ishosting.com/en/server-administration#fastpanel)
    - [Other](https://help.ishosting.com/en/server-administration#other)
- [Mail](https://help.ishosting.com/en/mail#main-content)

    - [Getting Started](https://help.ishosting.com/en/mail#getting-started)
    - [ispmanager](https://help.ishosting.com/en/mail#ispmanager)
    - [DirectAdmin](https://help.ishosting.com/en/mail#directadmin)
    - [VestaCP](https://help.ishosting.com/en/mail#vestacp)
    - [Other Issues](https://help.ishosting.com/en/mail#other-issues)
- [VPN](https://help.ishosting.com/en/vpn#main-content)

    - [Getting Started](https://help.ishosting.com/en/vpn#getting-started)
    - [Android](https://help.ishosting.com/en/vpn#android)
    - [iOS](https://help.ishosting.com/en/vpn#ios)
    - [macOS](https://help.ishosting.com/en/vpn#macos)
    - [Mikrotik](https://help.ishosting.com/en/vpn#mikrotik)
    - [Linux](https://help.ishosting.com/en/vpn#linux)
    - [Windows](https://help.ishosting.com/en/vpn#windows)
    - [Amnezia VPN](https://help.ishosting.com/en/vpn#amnezia-vpn)
    - [Hysteria](https://help.ishosting.com/en/vpn#hysteria)
- [Data Storage](https://help.ishosting.com/en/data-storage#main-content)

    - [Getting Started](https://help.ishosting.com/en/data-storage#getting-started)
    - [Backups](https://help.ishosting.com/en/data-storage#backups)
    - [Other](https://help.ishosting.com/en/data-storage#other)
- [SSL Certificates](https://help.ishosting.com/en/ssl-certificates#main-content)

    - [Getting Started](https://help.ishosting.com/en/ssl-certificates#getting-started)
    - [Install](https://help.ishosting.com/en/ssl-certificates#install)
- [Affiliate Program](https://help.ishosting.com/en/affiliate-program)
- [Additional Services](https://help.ishosting.com/en/additional-services#main-content)

    - [Additional IP](https://help.ishosting.com/en/additional-services#additional-ip)
    - [Control Panels](https://help.ishosting.com/en/additional-services#control-panels)
    - [Antivirus](https://help.ishosting.com/en/additional-services#antivirus)
- [Client Area](https://help.ishosting.com/en/client-area#main-content)

    - [Balance History](https://help.ishosting.com/en/client-area#balance-history)
- [Payment for Services](https://help.ishosting.com/en/payment-for-services#main-content)

    - [Getting Started](https://help.ishosting.com/en/payment-for-services#getting-started)
    - [My Account](https://help.ishosting.com/en/payment-for-services#my-account)
    - [Payments](https://help.ishosting.com/en/payment-for-services#payments)
    - [Other Issues](https://help.ishosting.com/en/payment-for-services#other-issues)
- [Documents and Policies](https://help.ishosting.com/en/documents-and-policies#main-content)

    - [General](https://help.ishosting.com/en/documents-and-policies#general)
    - [Company](https://help.ishosting.com/en/documents-and-policies#company)
- [Questions and Answers](https://help.ishosting.com/en/questions-and-answers#main-content)

    - [Control Panels](https://help.ishosting.com/en/questions-and-answers#control-panels)
    - [ispmanager](https://help.ishosting.com/en/questions-and-answers#ispmanager)
    - [Windows](https://help.ishosting.com/en/questions-and-answers#windows)
    - [Linux](https://help.ishosting.com/en/questions-and-answers#linux)
    - [Mail](https://help.ishosting.com/en/questions-and-answers#mail)
    - [Other](https://help.ishosting.com/en/questions-and-answers#other)
- [Special Offers](https://help.ishosting.com/en/special-offers)
- [is\*smart](https://help.ishosting.com/en/issmart#main-content)

    - [General Info](https://help.ishosting.com/en/issmart#general-info)
    - [Getting Started](https://help.ishosting.com/en/issmart#getting-started)
    - [API](https://help.ishosting.com/en/issmart#api)
    - [AI Models](https://help.ishosting.com/en/issmart#ai-models)
- [List of Apps](https://help.ishosting.com/en/list-of-apps)

[![is\*hosting](https://help.ishosting.com/hubfs/ishosting-logo-black.svg "is*hosting")](https://ishosting.com)

<https://www.facebook.com/ishostingcom> <https://twitter.com/ishostingcom> <https://www.instagram.com/is.hosting> <https://www.youtube.com/@ishosting> <https://www.linkedin.com/company/is-hosting>

Copyright © 2025, © Webrain OÜ