在Apache conf

时间:2017-06-07 23:58:52

标签: apache

我的apache配置存在问题。预期结果是允许所有流量进入默认站点trekfederation.com,除非指定子域并以其他方式匹配。我的问题是我的一些子域仍然默认为主站点。

我的配置中有两个文件:

 httpd.conf
 ships.conf

这是httpd.conf的虚拟主机部分:

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier 
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
    ServerName weather.trekfederation.com
    ServerAlias weather.trekfederation.com
    DocumentRoot "/var/www/html/weather"
</VirtualHost>

<VirtualHost *:80>
    ServerName oldsite.trekfederation.com
    ServerAlias oldstore.trekfederation.com
    DocumentRoot "/var/www/html/trekfed"
</VirtualHost>

<VirtualHost *:80>
    ServerName promenade.trekfederation.com
    Redirect / http://trekfederation.com/shop
</VirtualHost>

<VirtualHost *:80>
    ServerName donations.trekfederation.com
    Redirect / http://trekfederation.com/product-category/donations/
</VirtualHost>

Include conf.d/ships.conf

<VirtualHost *:80>
    ServerName trekfederation.com
    ServerAlias trekfederation.com www.trekfederation.com

Alias /phpmyadmin "/usr/share/phpMyAdmin"
<Directory "/usr/share/phpMyAdmin">
    DirectoryIndex index.php
    AllowOverride All
    Options FollowSymlinks
    Order allow,deny
    Allow from all
</Directory>

    ServerAlias www.iftcommand.com
    DocumentRoot "/var/www/html/trekweb"


</VirtualHost>




# Include conf.d/personal.conf


<VirtualHost *:80>
    ServerName ccc.trekfederation.com
    DocumentRoot "/var/www/html/ccc"
</VirtualHost>

Ships.conf:

<VirtualHost *:80>
    ServerName ussgeorgewashington.trekfederation.com
    ServerAlias ussgeorgewashington.trekfederation.net
    ServerAlias nfc1773a.trekfederation.com
    ServerAlias nfc1773a.trekfederation.net
    DocumentRoot /var/www/html/NOVA/USS_GEORGE_WASHINGTON
</VirtualHost>

<VirtualHost *:80>
    ServerName ussfarragut.trekfederation.com
    ServerAlias ussfarragut.trekfederation.net
    DocumentRoot /var/www/html/NOVA/USS_FARRAGUT
</VirtualHost>

<VirtualHost *:80>
    ServerName ussvortex.trekfederation.com
    ServerAlias ussvortex.trekfederation.net
    DocumentRoot /var/www/html/NOVA/USS_VORTEX
</VirtualHost>


<VirtualHost *:80>
    ServerName ussvictory.trekfederation.com
    ServerAlias ussvictory.trekfederation.net
    DocumentRoot /var/www/html/NOVA/USS_VICTORY
</VirtualHost>

<VirtualHost *:80>
    ServerName ussnavigator.trekfederation.com
    ServerAlias ussnavigator.trekfederation.net
    DocumentRoot /var/www/html/NOVA/USS_NAVIGATOR
</VirtualHost>

<VirtualHost *:80>
    ServerName ussfirelace.trekfederation.com
    ServerAlias ussfirelace.trekfederation.net
    DocumentRoot /var/www/html/NOVA/USS_FIRELACE
</VirtualHost>

我正在努力的网站是ussfirelace.trekfederation.com。它仍然路由到trekfederation.com。

它确实注册了apache -S:

     port 80 namevhost ussfirelace.trekfederation.com (/etc/httpd/conf.d/ships.conf:34)
             alias ussfirelace.trekfederation.net
我错过了什么? 感谢。

1 个答案:

答案 0 :(得分:0)

配置对我来说很好看。可能的解决方案/问题:

a)您是否重启了Apache以加载新的虚拟主机?

b)您是否检查过DNS记录是否为您的服务器的A记录(或CNAME),并且您的NS提供商没有配置重定向?

c)您是否检查过您的代码,它没有触发重定向(例如301或javascript ......)?

d)清除浏览器缓存也是你需要注意的事情。

e)仔细检查您输入拼写错误的网址。