We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.12.3. Redirects

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?site1.com [NC]
RewriteRule ^(. *) http: //www.site2.com/$1 [L,R=301]

Instead site1.com substitute the site address, from which a redirect should be performed, and instead of http://www.site2.com — on which.

Alternatively, you can use webredirect.

For a redirect with www.сайт.com on сайт.com:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.сайт.com$ [NC]
RewriteRule ^(.*)$ http://site.com/$1 [R=301,L]

Instead сайт.com substitute the address of your site for which the redirect is configured.

For a redirect with сайт.com on www.сайт.com:

RewriteEngine On 
RewriteBase / 
RewriteCond %{HTTP_HOST} ^сайт.com [NC] 
RewriteRule ^(. *) http: //www.site.com/$1 [L,R=301]

Instead сайт.com substitute the address of your site for which the redirect is configured.

Preliminary necessarily turnon processing requests to non-existent subdomains.

RewriteEngine On 
RewriteBase / 
RewriteCond %{HTTP_HOST} ^(.*).site.com [NC] 
RewriteRule ^(.*)$ http://site.com/$1 [L,R=permanent]

Instead сайт.com substitute the address of your site for which the redirect is configured.

RewriteEngine On 
RewriteBase / 
RewriteRule ^(.*)$ http://site.com/desired_page/ [L,R=permanent]

Instead http://site.com/desired_page/ substitute the page address of another site, to which a redirect must be performed

RewriteCond %{REQUEST_URI} ^/old/address/$
RewriteRule ^.*$ http://%{HTTP_HOST}/new/address/ [R=301,L]

Instead /old/address/ substitute the page address, with which a redirect should be performed, and instead of /new/address/ — to which.

RewriteCond %{REQUEST_URI} ^/old/address/$
RewriteRule ^.*$ http://site.com/new/address/? [R=301,L]

Instead сайт.com substitute the address of the new site, on which a redirect must be performed. Instead /old/address/ specify the page, with which you need to redirect, and instead of /new/address/to which.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:SSL} !=1 [NC]
RewriteRule ^(. *) https: //site.com/$1 [L,R=301]

Instead сайт.com substitute the address of your site for which the redirect is configured.

RewriteEngine On 
RewriteBase / 
RewriteCond %{HTTP:SSL} =1 [NC] 
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:SSL} !=1 [NC]
RewriteRule ^admin(.*)$ https://%{SERVER_NAME}/admin$1 [L,R]

Instead admin substitute the name of the directory for which the redirect is configured.

Note

Instead php you can specify any other file type that needs to be removed from the address, for example html.

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]

Attention!

Removing an extension from URL can adversely affect the operation of certain systems that use POST methods to send data to the script. It is important to keep in mind that such a rule can create problems for the site.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^.*$ $0.php [L,QSA]
RewriteCond %{THE_REQUEST} ([^\s]*)\.php(\?[^\s]*)?
RewriteRule (.*) %1 [R=301,L]

Instead php specify the extension you want.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteCond %{THE_REQUEST} //
RewriteCond %{QUERY_STRING} !http(s|)://
RewriteRule .* /$0 [R=301,L]