어떤 리디렉션 규칙 나는 아래에있는 모든 페이지 리디렉션을 사용하는 것이 olddomain.example
로 리디렉션을 newdomain.example
?
사이트는 구조가 완전히 다르므로 이전 도메인 아래의 모든 페이지 를 새 도메인 색인 페이지 로 리디렉션 하고 싶습니다 .
나는 이것이 olddomain.example 기본 디렉토리에 있다고 생각했다.
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.example/ [R=301]
그러나로 이동 olddomain.example/somepage
하면로 리디렉션됩니다 newdomain.example/somepage
. newdomain.example
페이지 접미사 가 없는 경우 에만 리디렉션이 필요합니다.
마지막 부분을 어떻게 유지합니까?
답변
다음과 같을 수 있습니다.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]
답변
아래 답변으로 인해 무한 리디렉션 루프가 발생할 수 있습니다 …
여기서는 URL의 도메인 이름 뒤의 모든 것을 새 도메인 URL의 동일한 사본으로 리디렉션합니다.
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
www.example.net/somepage.html?var=foo
로 리디렉션 www.newdomain.com/somepage.html?var=foo
답변
명확히하기 위해, 방해가 된 호스팅 리디렉션을 제거한 후 내 원래 솔루션도 작동합니다.
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]
답변
내 WordPress 블로그에 이것을 .htaccess로 사용했습니다. 그것은 변환 //www.blah.example/asad : HTTP , HTTP : //blah.example/asad , HTTP : //www.blah.example2/asad 등을 HTTP : //blah.example/asad
모두에게 감사를 다른 답변 나는 이것을 알아 냈습니다.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^YOURDOMAIN\.example$ [NC]
RewriteRule ^(.*)$ https://YOURDOMAIN.example/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
답변
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>
이것은 나를 위해 일했다
답변
이 작업을 수행하는 다양한 방법과 다양한 리디렉션이 있으며 아래에 나열했습니다.
301 (영구) 리디렉션 : 전체 사이트를 영구적으로 다른 URL을 가리 킵니다. 가장 일반적인 리디렉션 유형이며 대부분의 상황에서 유용합니다. 이 예에서는 “example.com”도메인으로 리디렉션합니다.
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://example.com/
302 (임시) 리디렉션 : 전체 사이트를 다른 임시 URL로 지정하십시오. 임시 방문 페이지가 있고 나중에 기본 방문 페이지로 다시 전환하려는 경우 SEO 목적에 유용합니다.
# This allows you to redirect your entire website to any other domain
Redirect 302 / http://example.com/
index.html을 특정 하위 폴더로 리디렉션하십시오.
# This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/
기존 파일을 새 파일 경로로 리디렉션하십시오.
# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
특정 색인 페이지로 리디렉션 :
# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html
답변
일부 위치에서 하위 도메인으로 리디렉션하려는 경우 다음을 사용할 수 있습니다.
Redirect 301 /Old-Location/ http://subdomain.yourdomain.com