Httpd服务入门知识-Httpd服务常见配置案例之定义路径别名
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.创建测试数据
[[email protected] ~]# mkdir -pv /data/downloads/
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/downloads/’
[[email protected] ~]#
[[email protected] ~]# cp -a /etc/sysconfig/network-scripts/ /data/downloads/
[[email protected] ~]#
[[email protected] ~]# ll /data/downloads/network-scripts/ | wc -l [[email protected] ~]#
[[email protected] ~]#
二.编辑httpd的配置文件
[[email protected] ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf | grep ServerRoot
ServerRoot "/etc/httpd"
[[email protected] ~]#
[[email protected] ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf | grep IncludeOptional
IncludeOptional conf.d/*.conf
[[email protected] ~]#
[[email protected] ~]# cat /etc/httpd/conf.d/alias.conf
<Directory "/data/downloads/network-scripts">
Options Indexes FollowSymLinks
Require all granted
</Directory>
alias /netScript /data/downloads/network-scripts #千万要注意,"/netScript"前面的"/"别忘记写了哟~,当客户端访问"/netScript"就会自动跳转到"/data/downloads/network-script"目录下去找index.html,若没有index.html文件就会遵守咱们配置的Options指令,会列出所有文件包括链接文件哟~
[[email protected] ~]#
[[email protected] ~]# systemctl reload httpd
[[email protected] ~]#