进入apache配置目录里
cd /etc/httpd/conf
用Vi编辑 httpd-vhosts.conf文件
vi httpd-vhosts.conf
找到以下内容:
ServerAdmin
DocumentRoot "/var/www/html/lampw.com/www"
ServerName lampw.com:80
ServerAlias *.lampw.com
ErrorDocument 404 /404.html
ErrorLog /var/www/html/log/lampw.com.error.log
CustomLog /var/www/html/log/lampw.com.CustomLog common
在 CustomLog /var/www/html/log/lampw.com.CustomLog common 代码下面添加以下内容:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^lampw\.com$ [NC]
RewriteRule ^(.*)$ [R=301,L]
ServerAdmin
DocumentRoot "/var/www/html/lampw.com/www"
ServerName lampw.com:80
ServerAlias *.lampw.com
ErrorDocument 404 /404.html
ErrorLog /var/www/html/log/lampw.com.error.log
CustomLog /var/www/html/log/lampw.com.CustomLog common
RewriteEngine on
RewriteCond %{HTTP_HOST} ^lampw\.com$ [NC]
RewriteRule ^(.*)$ [R=301,L]
完成后重启apache 服务
service httpd restart
设置完成
阅读(6933) | 评论(0) | 转发(0) |