.htaccess Apache2,在本地主机上设置动态子域

.htaccess Apache2,在本地主机上设置动态子域,.htaccess,apache2,subdomain,.htaccess,Apache2,Subdomain,简单的问题是怎么做 现在我有了这样的主机 <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName git.land DocumentRoot /home/sergey/public_html/git.land/public_html <Directory /> Options FollowSymLinks AllowOverride None </Directory> &

简单的问题是怎么做

现在我有了这样的主机

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName git.land

DocumentRoot /home/sergey/public_html/git.land/public_html

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory /home/sergey/public_html/git.land/public_html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
当我进入“”时,它显示正确的方向。但当我想进去的时候“是stucks。想了很多,然后在prev上重定向。页面(无子域)

我想将子域添加到localhost进行测试,但我不知道应该使用什么来进行测试。我知道一些卑鄙的事情,我试过了,但毫无用处


我还可以(也许)以某种方式将其从.htaccess中更改过来(我四处搜索,发现有人使用它们来获取子域名称,而不在主机中进行任何配置)。

此配置文件解决了此问题

<VirtualHost *:80>
    DocumentRoot /home/sergey/public_html/git.land/public_html
    ServerName other.land
    ServerAlias *.land
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName land
    DocumentRoot /home/sergey/public_html/git.land/public_html

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    <Directory /home/sergey/public_html/git.land/public_html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
    LogLevel warn 
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

DocumentRoot/home/sergey/public_html/git.land/public_html
ServerName.other.land
服务器别名*.land
服务器管理员webmaster@localhost
服务器名土地
DocumentRoot/home/sergey/public_html/git.land/public_html
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:debug、info、notice、warn、error、crit、alert、emerg。
日志级别警告
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
只有在主机中设置了所有案例(我是指子域)时,它才起作用

<VirtualHost *:80>
    DocumentRoot /home/sergey/public_html/git.land/public_html
    ServerName other.land
    ServerAlias *.land
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName land
    DocumentRoot /home/sergey/public_html/git.land/public_html

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    <Directory /home/sergey/public_html/git.land/public_html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
    LogLevel warn 
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>