0

Google은 내가 대체 한 웹 사이트의 색인을 생성했습니다. 기존의 URL 구조를 전달하고 싶지만 두 가지 문제가 있습니다.301 리디렉션 Mod-Rewrite (개별 파일로의 디렉토리)

1) http://www.abc.com/testimonials/http://www.abc.com/testimonials.html으로 리디렉션하려고하는데 작동하지 않습니다. 여기 무슨 일이 일어나는가?

a) WWW에서는 아무 일도 일어나지 않습니다. WWW없이 b)는, 그것은 testimonials.html을 리디렉션 /하지만 후행 여기

이 크게 감상 할 수있다 htaccess로 파일

rewriteengine on 
rewritecond %{HTTP_HOST} ^www.abc.com$ [OR] 
rewritecond %{HTTP_HOST} ^abc.com$ 
rewriterule ^testimonials$ "http\:\/\/abc\.com\/testimonials\.html" [R=301,L] 

이 작업을 얻을 수있는 어떤 조언에 내가 가진 코드 슬래시. 당신이 사이트 이름에서 "WWW"를 삭제하지 않는 경우

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www\.abc\.com$ [OR] 
RewriteCond %{HTTP_HOST} ^abc\.com$ 
RewriteRule ^/testimonials/$ http://abc.com/testimonials.html [R=301,L] 

는이 코드를보십시오 :

답변

0

이 코드를 시도

의 mod_rewrite를 사용하는 방법 좋은 사례가있다
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www\.abc\.com$ [OR] 
RewriteCond %{HTTP_HOST} ^abc\.com$ 
RewriteRule ^/testimonials/$ /testimonials.html [R=301,L] 

: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond

+0

아직 실제 testimonials.html /로 이동합니다. 내가 가지고있는 다른 코드는 다음과 같습니다. 'code'RewriteCond % {THE_REQUEST}^[AZ] {3,9} \ /(.*) 색인 \. (html? php | asp | cfm) \ HTTP/ RewriteRule^(. *) 색인 \ (html? php | asp | cfm) $ http://www.abc.com/$1 및 RewriteCond % {HTTP_HOST}^abc \ .com $ [NC] RewriteRule^(. *) $ http://www.abc.com/$1 [L, R = 301]'코드' –

+0

그들은 무엇을하고 있습니까? 요청을 abc.com 폴더 (사이트 아님)로 리디렉션합니까? 사이트로 리디렉션하려면 사이트 이름 앞에 "http : //"를 추가해야합니다. 이 상황에서도 마지막 RewriteRule은 항상 같은 위치로 리디렉션됩니다. 나는 약간의 대답으로 코드를 변경했고 아파치를 다시 시작하는 것을 잊지 않았다. –