
나는 ModRewrite 규칙과 조건에 대해 약간의 조사를 했지만 내가 원하는 효과를 달성하는 만족스러운 규칙/조건 세트를 찾지 못했습니다.
기본적으로 도메인 A에 디렉터리가 있습니다(http://www.domaina.com/dir/) 도메인 B(http://www.domainb.com/diff_dir/).
사용자가 domaina의 /dir/에 액세스하려고 하는 경우에만 다시 쓰기 규칙을 적용하고 싶습니다. 다른 디렉토리나 루트에 액세스하는 경우 URL을 다시 작성하고 싶지 않습니다.
감사합니다!
답변1
도메인 구성에서:
#redirect everything under dir to the same location under domainb.com/diff_dir
RewriteRule ^/dir/(.*)$ http://www.domainb.com/diff_dir/$1 [r=301]
#redirect url http://www.domaina.com/dir to http://www.domainb.com/diff_dir
RewriteRule ^/dir(/)?$ http://www.domianb.com/diff_dir [r=301]
나는 이것을 테스트하지 않았지만 작동해야합니다.
참고:
루트 .htaccess 파일이나 특정 디렉터리 구성에서 이 작업을 수행하는 경우 선행 '/'를 삭제하거나 규칙 패턴을 조정해야 합니다. .^dir(/)?$