.htaccess перенаправляет сайт на страницу «Индекс» вместо перенаправления на указанный домен - PullRequest
0 голосов
/ 06 сентября 2018

Я недавно изменил перенаправления моего файла .htaccess. Причиной этого было то, что не работали отдельные ссылки RedirectPermanent моего старого файла, которые указывают на определенные страницы. Это потому, что раньше у меня был код подстановки сверху. Единственной вещью, которая работала, был мой главный редирект от этого.

С новым кодом я попытался поставить код RedirectPermanent сверху. Теперь ничто не перенаправляет вообще. При переходе на сайт я получаю страницу «Индекс» (см. Ниже img).

Кто-нибудь видит, что я делаю неправильно с моим новым кодом, чтобы он не работал?

enter image description here

Новейший - без перенаправления

RewriteEngine On

# These redirects must execute first,
# there are url changes on destination server

RedirectPermanent /about-us.html  https://newdomain.com/about
RedirectPermanent /about-us/t-slotted-aluminum-profiles.html  https://newdomain.com/profile
RedirectPermanent /about-us/t-slot-nuts-fasteners.html https://newdomain.com/components
RedirectPermanent /about-us/customer-service.html  https://newdomain.com/about

# Now that there are no more url changes, 
# Wildcard everything else to new domain

RewriteCond %{HTTP_HOST} ^oldDomain.com$
RewriteRule (.*) https:/newdomain.com/$1 [R=301,L]

Предыдущий код

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?oldDomain\.com$ [NC]
RewriteCond %{THE_REQUEST} !/administrator [NC]

RedirectPermanent /about-us.html  https://newDomain.com/about
RedirectPermanent /about-us/t-slotted-aluminum-profiles.html  https://newDomain.com/profile
RedirectPermanent /about-us/t-slot-nuts-fasteners.html https://newDomain.com/components
RedirectPermanent /about-us/customer-service.html  https://newDomain.com/about

RewriteRule ^ https://newDomain.com%{REQUEST_URI} [L,R=301,NE]

1 Ответ

0 голосов
/ 07 сентября 2018

Похоже, вы что-то упустили. Попробуйте это

RewriteEngine On 

# These redirects must execute first,
# there are url changes on destination server

RedirectPermanent /about-us.html  https://newdomain.com/about
RedirectPermanent /about-us/t-slotted-aluminum-profiles.html  https://newdomain.com/profile
RedirectPermanent /about-us/t-slot-nuts-fasteners.html https://newdomain.com/components
RedirectPermanent /about-us/customer-service.html  https://newdomain.com/about

# Now that there are no more url changes, 
# Wildcard everything else to new domain

RewriteCond %{HTTP_HOST} !^newDomain\.com 
RewriteRule (.*) https://newDomain.com/$1 [R=301,L] 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...