htaccess 기존 사이트를 2 개의 다른 도메인으로 리디렉션합니다

StackOverflow https://stackoverflow.com/questions/823131

  •  05-07-2019
  •  | 
  •  

문제

좋아, 그래서 그녀는 시나리오입니다 :

호스트의 루트 디렉토리에 블로그를 얻은 다음 fsgallery라는 하위 폴더에서 일부 앱을 호스팅했습니다. 이제 블로그의 새로운 도메인과 앱의 다른 도메인을 구입했습니다. II는 기존 디렉토리를 해당 새 영역으로 리디렉션하기 위해 적절한 HTACCESS 301 리디렉션을 알고 싶습니다.

다음은 샘플 DIR 구조입니다.

root/
  /app
  [blog]

시도 : Redir /App to NewdomainforApp.com redir [blog] to NewdomainforBlog.com으로

또한 원래 내 앱은 다음과 같은 URL 매개 변수를 수락하는 데 사용되었습니다 : App/User/1234567

그래서 나는 또한 : redir/app/user/{dynamic int parameter} to newdomainforapp.com/profile/ {dynamic int parameter}를 원합니다.

누구든지 나에게 플록을 도울 수 있습니까?

도움이 되었습니까?

해결책

보인다 재 작성S는 잘 작동해야합니다.

RewriteEngine on
RewriteRule ^/?app/user/([0-9]+) http://newdomainforapp.com/profile/$1 [R=301,L]
RewriteRule ^/?app(/(.*))?$ http://newdomainforapp.com/$2 [R=301,L]
RewriteRule ^/?(.*) http://newdomainforblog.com/$1 [R=301,L]

기사를 올바르게 리디렉션하기 위해 그룹과 함께 놀아야 할 것입니다.

다른 팁

아마도 프로그래밍 관련이 아니라 어쨌든 :이를 수행하는 올바른 방법은 가상 호스트 구성 파일에 있습니다 (즉 <VirtualHost *:80> ... </VirtualHost> 섹션)은 아닙니다 .htaccess 파일. 사용하는 지침은 다음과 같습니다

 RedirectMatch permanent /app/user/([0-9+]) http://newdomainforapp.com/profile/$1
 Redirect permanent /app http://newdomainforapp.com
 Redirect permanent / http://newdomainforblog.com
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top