隐藏系统和 Apache 的版本信息
方法一:
※首先修改源文件,再进行 make && make install 编译安装 编辑源文件/usr/local/apache2/include/ap_release.h 文件 [root@Nagios-Server include]# vimap_release.h
#define AP_SERVER_BASEPRODUCT "IIS"
#define AP_SERVER_MAJORVERSION_NUMBER 7
#define AP_SERVER_MINORVERSION_NUMBER 0
#define AP_SERVER_PATCHLEVEL_NUMBER 0
#define AP_SERVER_DEVBUILD_BOOLEAN 0 编辑源文件/usr/local/apache2/include/os.h 文件 [root@Nagios-Server include]# vimos.h
#define PLATFORM "Win32" 方法二:
[root@Nagios-Server include]# vim /usr/local/apache2/conf/httpd.conf
# Various default settings
Include conf/extra/httpd-default.conf
[root@Nagios-Server include]# vim /usr/local/apache2/conf/extra/httpd-default.conf
#ServerTokens Prod
#ServerSignature off
HTTP/1.1 200 OK
Date: Sun, 07 Dec 2014 11:55:51 GMT
Server: Apache/2.2.23 (Unix) PHP/5.4.1 #此处无法去掉,若要隐藏,只有用方法一 Last-Modified: Sat, 06 Dec 2014 07:22:37 GMT
ETag: "42760-19-509870ed29d1c" Accept-Ranges: bytes
Content-Length: 25
Content-Type: text/html
Apache rewrite 规则的配置
安装模块 mod_rewrite.so
修改 httpd.conf 文件开启 mode_rewrite.so
vim /etc/httpd/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so ##检查确定开启此行
创建基于域名的虚拟主机
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost *:80> ServerAdmin hunk.test.com DocumentRoot "/var/www/html/hunk" ServerName 192.168.10.201
RewriteEngine on ##打开 rewirte 功能 Include conf.d/hunk-rewrite.conf
</VirtualHost>
写 rewrite 规则
[root@localhost ~]# vim /etc/httpd/conf.d/hunk-rewrite.conf
RewriteCond %{HTTP_HOST} hunk.test.com [NC]
RewriteRule ^(.*)/index.html$ http://hunk.test.com/test.html [L,R=302]
在/var/www/html/hunk 添加测试页面。
[root@localhost ~]# vim /var/www/html/hunk/index.html
<html>
<title>
test page
</title>
</head>
<body >
<p align="center">
<font size="32px" color="red">
this is test page !page jump failure!
</font>
</p>
</body>
</html>
[root@localhost ~]# vim /var/www/html/hunk/hunk.html
<html>
<head>
<title>
test page
</title>
</head>
<body >
<p align="center">
<font size="32px" color="red">
this is test page !page jump success!
</font>
</p>
</body>
</html>
修改 hosts 文件
xp:C:\Windows\System32\drivers\etc\hosts
192.168.10.246 hunk.test.com ##添加此行 访问 hunk.test.com/index.html
this is test page !page jump success! [root@localhost ~]# vim /etc/hosts
192.168.10.40 hunk.test.com
[root@localhost ~]# elinks --dump hunk.test.com/index.html
this is test page !page jump success!
注意事项
1.书写 rewrite 需要知道正则表达式的知识。
在 RewriteRule ^(.*)/index.html$ http://hunk.test.com/test.html [L,R=302]中,^表示以某 某开头,$表示以某某结尾, .(点)表示匹配任意单个字符,*表示匹配前面的子表达式零次或多次(大
于等于 0 次)
2.这里搭建的是基于域名的虚拟主机的 web 服务器,所以下面两行代码是在
/etc/httpd/conf.d/vhosts.conf 书写。说明是此服务器也就是 hunk.test.com 打开 rewrite 功能,
并应用规则。
RewriteEngine on ##打开 rewirte 功能
Include conf.d/hunk-rewrite.conf
如果不是基于虚拟主机的 web 服务器,上面两行需要在/etc/httpd/conf/httpd.conf 书写。