Перенаправление всех страниц с сайта A на сайт B, включая http & https - PullRequest
0 голосов
/ 20 января 2019

Я недавно перенес все со старого сайта на новый, и я пытаюсь сделать перенаправления, чтобы набирать https://www.oldsite.com (и другие варианты, такие как http://www.oldsite.com, https://oldsite.com и http://oldsite.com) автоматически переходят на https://www.newsite.com.

Я успешно создал файл .htaccess, который делает все, что мне нужно (включая http://www.oldsite.com, перенаправляющий на https://www.newsite.com), но единственная часть, которую я не могу сделать, это сделать https://www.oldsite.com или любые подстраницы (https://www.oldsite.com/*) перенаправить на эквивалентную страницу на новом сайте (структуры страниц на обоих сайтах идентичны, только разные доменные имена).

Мне пришлось войти в GoDaddy и создать ручные перенаправления для важных страниц (которые автоматически генерировали большую часть кода), поэтому код, который я собираюсь показать, кажется длинным.Мои два домена настроены так, что старый сайт теперь является «дополнительным доменом» нового сайта, то есть на главном сайте есть папка с новым сайтом, каждый из которых имеет отдельные файлы htaccess.

Как я могух эти перенаправления?Я перепробовал множество твиков, у которых не все работает.

Вот код .htaccess для нового сайта (родительский каталог старого сайта - это может быть только первые 5 строк или около того, которые делают это, поскольку большая часть кода - это просто каждое ручное перенаправление, автоматически генерируемое из GoDaddy):

RewriteOptions inherit

ErrorDocument 404 https://www.newsite.com/other/404-error.html

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?oldsite\.com
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^newsite.com [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteRule ^(.*)$ https://www.newsite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^hosting$ "http\:\/\/www\.dpbolvw\.net\/click\-8487961\-11003096" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^checker$ "https\:\/\/www\.newsite\.com\/tools\/domain\-name\-checker\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ecommerce$ "https\:\/\/www\.newsite\.com\/ecommerce\-store\-woocommerce\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebay\/?$ "https\:\/\/www\.newsite\.com\/ebay\/free\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebaypro$ "https\:\/\/www\.newsite\.com\/ebay\/pro\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^other\/ebay\-template\.html$ "https\:\/\/www\.newsite\.com\/ebay\/free\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebaycheats$ "https\:\/\/www\.newsite\.com\/ebay\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebaycheat$ "https\:\/\/www\.newsite\.com\/ebay\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emprovider$ "https\:\/\/www\.getresponse\.com\/\?a\=oldsite" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emailprovider$ "https\:\/\/www\.getresponse\.com\/\?a\=oldsite" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^em$ "https\:\/\/www\.newsite\.com\/email\-marketing\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^email$ "https\:\/\/www\.newsite\.com\/email\-marketing\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emails$ "https\:\/\/www\.newsite\.com\/email\-marketing\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emcheat$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emcheats$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emailcheat$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emailcheats$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^photography$ "https\:\/\/www\.newsite\.com\/resources\.html\#photography\-tools" [R=301,L]
RewriteCond %{HTTP_HOST} ^newsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.newsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^photography\.html$ "https\:\/\/www\.newsite\.com\/resources\.html\#photography\-tools" [R=301,L]

А вот код .htaccess для старого сайта (опять же, может быть, просто первые 5 строк или около того):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.newsite\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^hosting$ "https\:\/\/www\.newsite\.com\/hosting" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^checker$ "https\:\/\/www\.newsite\.com\/tools\/domain\-name\-checker\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ecommerce$ "https\:\/\/www\.newsite\.com\/ecommerce\-store\-woocommerce\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebay\/?$ "https\:\/\/www\.newsite\.com\/ebay\/free\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebaypro$ "https\:\/\/www\.newsite\.com\/ebay\/pro\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^other\/ebay\-template\.html$ "https\:\/\/www\.newsite\.com\/ebay\/free\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebaycheats$ "https\:\/\/www\.newsite\.com\/ebay\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebaycheat$ "https\:\/\/www\.newsite\.com\/ebay\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emprovider$ "https\:\/\/www\.newsite\.com\/emprovider" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emailprovider$ "https\:\/\/www\.newsite\.com\/emailprovider" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^em$ "https\:\/\/www\.newsite\.com\/email\-marketing\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^email$ "https\:\/\/www\.newsite\.com\/email\-marketing\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emails$ "https\:\/\/www\.newsite\.com\/email\-marketing\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emcheat$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emcheats$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emailcheat$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^emailcheats$ "https\:\/\/www\.newsite\.com\/email\-marketing\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^photography$ "https\:\/\/www\.newsite\.com\/resources\.html\#photography\-tools" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^photography\.html$ "https\:\/\/www\.newsite\.com\/resources\.html\#photography\-tools" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.html$ "https\:\/\/www\.newsite\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebay\.html$ "https\:\/\/www\.newsite\.com\/ebay\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebay\/pro\-template\.html$ "https\:\/\/www\.newsite\.com\/ebay\/pro\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebay\/free\-template\.html$ "https\:\/\/www\.newsite\.com\/ebay\/free\-template\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ebay\/cheat\-sheet\.html$ "https\:\/\/www\.newsite\.com\/ebay\/cheat\-sheet\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^resources\.html$ "https\:\/\/www\.newsite\.com\/resources\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ecommerce\-store\-woocommerce\.html$ "https\:\/\/www\.newsite\.com\/ecommerce\-store\-woocommerce\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^other\/new\-subscriber\.html$ "https\:\/\/www\.newsite\.com\/other\/new\-subscriber\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^other\/welcome\-back\.html$ "https\:\/\/www\.newsite\.com\/other\/welcome\-back\.html" [R=301,L]

Любые предложения будут высоко оценены, поскольку я озадачен, спасибо.

Примечание. Я думаю, что родительский файл .htaccess влияет на дочерний файл .htaccess.

Кроме того, для лучшего объяснения этого я бы просто хотел, чтобы любой вариант URL сайта oldsite.com направлялся натот же вариант newsite.com (например, https://www.oldsite.com/somepage.html перенаправит на https://www.newsite.com/somepage.html,, поэтому только oldsite будет заменен на newsite).

1 Ответ

0 голосов
/ 26 января 2019

Вы можете вставить это правило чуть ниже RewriteEngine On строка :

RewriteEngine On

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^(?:www\.)?oldsite\.com$ [NC]
RewriteRule ^ https://www.newsite.com%{REQUEST_URI} [L,R=301,NE]

Также в качестве примечания вы можете заменить везде на эти 2 строки:

RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$

С этими единственными условиями:

RewriteCond %{HTTP_HOST} ^(?:www\.)?oldsite\.com$ [NC]
...