我使用Apache的虚拟主机作为greptweet.com的大量子域,其中每个twitter用户名都是一个子域,比如<username>
.greptweet.com。问题是..。子域不能有下划线!:)
现在,我已经对站点进行了重组,我希望永久地将所有要进入子域的用户重定向到路径:
<username>
.greptweet.com到路径结构greptweet.com/u/<username>
例如http://kaihendry.greptweet.com/到http://greptweet.com/u/kaihendry/
理想情况下,我希望在Apache httpd.conf <VirtualHost>
节中实现这一点,而不是将位写入/srv/www/。
发布于 2011-11-04 15:26:33
像这样的东西会有用的:
<VirtualHost *:80>
ServerName kaihendry.greptweet.com
ServerAlias *.greptweet.com
DocumentRoot /var/www/localhost/htdocs/
Include /etc/apache2/vhosts.d/default_vhost.include
<Directory "/var/www/localhost/htdocs">
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.greptweet\.com [NC]
RewriteRule ^(.*)$ http://greptweet.com/u/%1 [R,L]
</VirtualHost>
https://serverfault.com/questions/327829
复制相似问题