apache 多个虚拟主机配置 及重写

修改http.conf 在最后或者 host 那段下面添加 或者直接修改   httpd-vhosts.conf也可以,但是要在下面开启引用。
NameVirtualHost *:80


<Directory "/var/www/www">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<Directory "/var/ftp">
    Options FollowSymLinks Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>


<VirtualHost *:80>
    ServerName    linux.centos.vbird
    DocumentRoot  /var/www/html
</VirtualHost>
<VirtualHost *:80>
    ServerName    www.centos.vbird
    DocumentRoot  /var/www/www
    CustomLog     /var/log/httpd/www.access_log combined
  
</VirtualHost>
<VirtualHost *:80>
    ServerName    ftp.centos.vbird
    DocumentRoot  /var/ftp
</VirtualHost>
开启后只能通过 域名访问 如果通过ip访问会默认进入进入第一个地址,要调整顺序的话只需要调整他们的位置就好了。

重写配置

<Directory "/web/baidu">

        Options Indexes followsymlinks

        AllowOverride all

        Order allow,deny

        Allow from all

</Directory>

.htaccess文件规则
<IfModule mod_rewrite.c>


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

 
 
 
  
  
  
  

你可能感兴趣的:(apache,多个,虚拟主机,重新)