2017-01-26 1 views
0

http://example.com이 있는데 orange.1.php, orange.2.php, orange.32.5.php 등의 트래픽을 모두 http://newexample.com으로 리디렉션하려면 어떻게해야합니까? .htaccess를 작성 하시겠습니까? 그냥 확실하게하려면 http://example.com/blah은 으로 리디렉션해야하고 http://newexample.com/blah이 아닌 리디렉션해야합니다. 한 시간 씩 다른 것을 시도해 봤는데 아무도 작동하지 않는 것 같아.하나의 패턴을 제외한 모든 파일을 새 사이트로 리디렉션

나는이 일을해야한다고 생각 :

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^example\.com$ [OR] 
RewriteCond %{HTTP_HOST} ^www\.example\.com$ 
RewriteCond %{REQUEST_URI} !^orange\.[0-9]+.*$ 
RewriteRule ^/?.*$ "http:\/\/newexample\.com" [R=301,L] 

감사합니다!

답변

0

REQUEST_URI은 항상 슬래시로 시작합니다. 불행하게도,이 http://newexample.com에 example.com에서 어떤 URL을 리디렉션

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC] 
RewriteRule !^orange\.\d+\.php$ http://newexample.com/? [R=301,L,NC] 
+0

:

은이 리팩토링 짧은 규칙을 사용할 수 있습니다. –

+0

이것이 가장 먼저 적용되고 브라우저 캐시가 완전히 지워져 있는지 확인하십시오. – anubhava

관련 문제