1

大家好,

我正在尝试为我的用户创建一个动态子域,例如username.host.com而不是www.host.com/user.php?user=username

为此,我在我的主机中创建了一个记录,例如 *.mosto.in 208.91.199.44 Active

在我的 .htaccess 文件中,我添加了以下内容

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.mosto\.in$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^www\.([^.]+)\.mosto\.in(.*) /home/$1$2

以上代码我在Apache官网http://httpd.apache.org/docs/2.0/misc/rewriteguide.html#content上找到的

但是当我试图打开dev.mosto.in时没有打开。

任何线索或想法?我在哪里做错了?

4

2 回答 2

1

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.
RewriteRule ^$ http://www.mosto.in/user.php?user=%1 [L,QSA,R]
于 2013-09-12T17:08:35.430 回答
0
RewriteEngine On

# Redirecting wildcard subdomains to store.php
RewriteCond %{HTTP_HOST} ^(^.*)\.mosto.in
RewriteRule (.*)  store.php?store=%1

解决了我的问题。

于 2013-09-13T02:22:52.940 回答