2012-07-21 6 views
0

사용자에게 개인 서브 도메인을 할당하기 위해 mod_rewrite를 작성하는 데 도움이 필요합니다.와일드 카드 하위 도메인에 대한 mod_rewrite

나는

을 sub.domain.com/profile?user=sub하는 sub.domain.com을 변환하고자하지만 사용자가 어떤 페이지가 열립니다 경우 '사용자'변수는

서브 즉 전달해야 .domain.com에/페이지

그것은 더 리디렉션, 즉 마스크해야 sub.domain.com/page?user=sub하는 문서 루트에 htaccess로 파일이 추가

답변

1

시도

# for/requests 
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC] 
# this step may not be necessary if you don't care about "www.domain.conm" 
RewriteCond %1 !www 
RewriteRule ^$ /profile?user=%1 [QSA,L] 

# for any "page" 
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC] 
# this step may not be necessary if you don't care about "www.domain.conm" 
RewriteCond %1 !www 
RewriteRule ^(.*)$ /$1?user=%1 [QSA,L] 
+0

도움을 주신 John Lin에게 감사드립니다. –

관련 문제