2012-07-26 3 views
0

나는 새로운 도메인으로 이전 도메인을 리다이렉션하려고 시도하지만, 제자리에 넣어야 할 몇 가지 규칙이 있으며 지금까지 나는 그걸 제대로 관리하지 못했습니다.아파치 모드 다시 쓰기 규칙 특별 조건

www.old-domain.com/sheffield/ www.old-domain.com/london :

이전 도메인 예를 들어 www.old-domain.com이 같은 영국의 도시 후 폴더 이름의 수백이있다/ www.old-domain.com/essex/

각 폴더 안에는 index.html 파일과 가능한 다른 디렉 토리스 및 파일이 있습니다.

이전 도메인/마을이 새 도메인/마을에 매핑되지만 이전 도메인/town/index.html이 새 도메인 끝에 index.html을 삽입하지 않도록 이러한 방법으로 새 ​​도메인에 리디렉션해야합니다. 타운 이후의 경로는 index.html 이외의 것으로 새로운 도메인의 경로로 리디렉션됩니다.
죄송 합니다만 설명하기가 쉽지 않으며 읽지 않고 쉽게 찾을 수 없습니다.

www.old-domain.com/sheffield => www.new-domain.com/sheffield

www.old-domain.com/sheffield/ => www.new-domain.com/셰필드/

www.old-domain.com/sheffield/index.html => www.new-domain.com/sheffield/

www.old-domain.com/sheffield/main.html => www.new-domain.com/sheffield/main.html

www.old-domain.com/sheffield/innerFolder/ => www.new-domain.com/sheffield/innerFolder

www.old-domain.com/sheffield/innerFolder/file.php => www. new-domain.com/sheffield/innerFolder/file.php

굵게 두 사람은 나는 이것에 의해 작동 얻을 관리 위 :

Options +FollowSymLinks 
RewriteEngine on 
RewriteRule ^sheffield/(.*)$ http://www.new-domain.com/sheffield/$1 [R=301,L] 

그러나 임 정말 old-domain.com/sheffield 얻기 위해 고군분투 /index.html 새 도메인에 .index.html을 넣지 마십시오.

더 이상 mod 재 작성 튜토리얼을보고 머리카락을 뽑기 전에 다른 사람이이 문제를 해결할 수 있습니까?

답변

0

약 4 ~ 5 시간이 지난 후에 다른 조합을 시도하고 신을 읽고 얼마나 많은 재 작성 튜토리얼을 읽었는지 알 수 있습니다. htacess 파일은 이제는 모두 훌륭하게 작동하는 3 개 위치에 대해서만 사용합니다.

Options +FollowSymLinks 
RewriteEngine on 

RewriteRule ^sheffield\/index\.html http://www.new-domain.co.uk/sheffield/ [R=301,L] 
RewriteRule ^sheffield/(.*)$ http://www.new-domain.co.uk/sheffield/$1 [R=301,L] 

RewriteRule ^bolton\/index\.html http://www.new-domain.co.uk/bolton/ [R=301,L] 
RewriteRule ^bolton/(.*)$ http://www.new-domain.co.uk/bolton/$1 [R=301,L] 

RewriteRule ^coventry\/index\.html http://www.new-domain.co.uk/coventry/ [R=301,L] 
RewriteRule ^coventry/(.*)$ http://www.new-domain.co.uk/coventry/$1 [R=301,L] 
+1

다르게 전달 될 디렉토리가 없으면 추가로 간단하게 만들려고합니다. RewriteRule^(. *) \/index \ .html http://www.new-domain.co.uk/$ 1/[R = 301, L] RewriteRule^(. *) $ http://www.new-domain.co.uk/$1 [R = 301, L] –

+0

감사합니다. 당신의 논리를 봅니다. 한 번에 모든 위치를 리디렉션하지 않으므로이 작업을 잠시 할 수 없습니다. 여기서 우리는 대략 SEO 순위에 대해 걱정하고 있습니다. 그래서 약 3500 개의 위치 중 약 10 개 지점에서 해보았습니다.하지만 스왑을 끝낼 때마다 확실히 돌아와서 다시 귀하의 사례를 살펴볼 것입니다. 시간 내 주셔서 다시 한 번 감사드립니다. – azzy81

2

힌트 : 다시 쓰기 규칙은 처음으로 일치하는 기준으로 처리됩니다. 주 규칙 앞에 예외를 둘 수 있습니다.

+0

감사합니다. Mod Rewrite는 지뢰밭과 같습니다. 그것의 정규식과 동등한 ... 그냥 복잡한 규칙과 무작위 전문 용어의 톤은 거의 언제나 정확한 패턴을 얻기 위해 연령이 오래 걸립니다. 그러나 나는 그것을 밖으로 작동하고 아래에 내가 한 것입니다. – azzy81