0

ユーザーに独自の個人用サブドメインを割り当てる mod_rewrite を作成する際に助けが必要です。

sub.domain.com を sub.domain.com/profile?user=sub に変換したい

ただし、ユーザーが任意のページを開く場合は、「user」変数も渡す必要があります。

sub.domain.com/page から sub.domain.com/page?user=sub

マスクする必要があります。つまり、リダイレクトはありません

4

1 に答える 1

1

これをドキュメントルートのhtaccessファイルに追加してみてください

# 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]
于 2012-07-21T20:02:32.367 に答える