example.com/profile.php?UserName=xxxx
에서 xxxx.example.com
xxxx에는 a-z 또는 0-9가 포함되어 있습니다. 나는 (이 사이트에서 일부를) 코드를 시도했지만 내가 원하는대로 작동하지 않았다. 당신은 당신의 리디렉션 규칙 전에 내부 라우팅 규칙을 모두 둘 필요가htaccess는 PHP 파일에서 하위 도메인으로 다시 작성합니다.
RewriteEngine on
#this should redirect example.com/profile.php?UserName=x to x.site.com
RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9-_]+).example.com [NC]
RewriteRule (.*) %1/$1 [QSA,L]
#if link does not contain subdomain add www
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
당신이 원하는 'xxxx.example.com'에'www.example.com/profile.php? UserName = xxxx'의 내용을 보여주기 위해서입니다. 권리? – undone
예 ... xxxx가 변경되며 영문 소문자와 숫자 만 포함될 수 있습니다. – shnisaka
마지막 두 개의 다시 쓰기 규칙을 제거하고 다시 시도하면 어떻게됩니까? – Ben