Apache添加虚拟主机及伪静态
作者:shao65308 日期:2009-12-24
利用Apache添加虚拟主机
1、示例代码:
#<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>
2、亲测代码:
<VirtualHost *:80>
DocumentRoot /home/www/xxx
ServerName xxx.com
ServerAlias *.xxx.com
DirectoryIndex default.php default.htm index.php index.htm
//此处可添加伪静态代码
RewriteEngine on //开启重写状态
RewriteRule ^/news_list_([a-z]+)_([0-9]+).html$ /news_list.php?id=$2&action=$1 //需伪静态的页面
//此处可添加伪静态代码
<Directory "/home/www/xxx">
Options None
AllowOverride None
order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
1、示例代码:
#<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>
2、亲测代码:
<VirtualHost *:80>
DocumentRoot /home/www/xxx
ServerName xxx.com
ServerAlias *.xxx.com
DirectoryIndex default.php default.htm index.php index.htm
//此处可添加伪静态代码
RewriteEngine on //开启重写状态
RewriteRule ^/news_list_([a-z]+)_([0-9]+).html$ /news_list.php?id=$2&action=$1 //需伪静态的页面
//此处可添加伪静态代码
<Directory "/home/www/xxx">
Options None
AllowOverride None
order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
评论: 0 | 引用: 0 | 查看次数: 2791
发表评论
你没有权限发表评论!