Change domain site

Htaccess quick question

I am changing the domain associated with the site and want to know if I can configure htaccess to create the following types of redirects:

Redirection http://www.oldomain.com/contact-us

until http://www.newdomain.com/contact-us

Basically a global redirect that redirects to the new domain but saves the rest of the URL that the user typed.

UPDATE: I ended up using the following code and it works great

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
+3
source share
3 answers

, , RewriteEngine. (RewriteEngine , , , - .)

Redirect permanent / http://newdomain.com/

Redirect -, , . Redirect :

:

Redirect /service http://foo2.bar.com/service

http://myserver/service/foo.txt, http://foo2.bar.com/service/foo.txt.

+3

.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldname\.com
RewriteCond %{REQUEST_URI} ^oldname\.com
RewriteRule ^(.*)$ http://www.newname.com/$1 [R=301,QSA,L]
+2

Batfan,

httpd, , NameVirtualHost httpd.conf. . http://httpd.apache.org/docs/2.0/mod/core.html#namevirtualhost

By default, httpd is not configured for name-based shared hosting. You must enable this through NameVirtualHost. Then try doing the redirects, as suggested by Greg Hugill.

Let us know if this works.

Thank Ismael Kazimpan

+1
source

Source: https://habr.com/ru/post/1785694/


All Articles