如何创建指向文件夹的虚拟子域?

时间:2016-06-19 18:54:49

标签: .htaccess url url-rewriting subdomain

我正在尝试创建一个可以创建其投资组合的网站,目前曾创建过具有网址domain.com/content/username的网页,但我想为每个用户username.domain.com创建一个子网域。你知道怎么做吗?我试过这个:

Options +FollowSymLinks -Multiviews
RewriteEngine on
RewriteBase /
#
# Canonicalize the hostname
RewriteCond www.%{HTTP_HOST} ^(www)\.(mine-app\.fr) [OR]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.(mine-app\.fr) [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.(mine-app\.fr) [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.(mine-app\.fr). [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.(mine-app\.fr):[0-9]+
RewriteRule (.*) http://%1.%2/$1 [R=301,L]
#
# If subdomain is NOT www
RewriteCond %{HTTP_HOST} !^www\.mine-app\.fr [NC]
# Extract (required) subdomain to %1
RewriteCond %{HTTP_HOST} ^([^.]+)\.mine-app\.fr$
# Rewrite if requested URL resolves to existing file or subdirectory in /content/<content>/ path
RewriteCond %{DOCUMENT_ROOT}/content/%1/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/%1/$1 -d
RewriteRule (.*) /content/%1/$1 [L]

但没有任何效果。我该如何解决这个问题?

0 个答案:

没有答案
相关问题