Apache httpd 2.4 alias 别名配置

简介: Web网站别名配置是被经常使用的一个特性。这个功能实际上是为站点URI定义一个路径映射关系,其配置和使用也较为简单。

Web网站别名配置是被经常使用的一个特性。这个功能实际上是为站点URI定义一个路径映射关系,其配置和使用也较为简单。以下是基于CentOS 7下实现alias的别名配置,供大家参考。

配置示例

[root@centos7-web ~]# more /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

[root@centos7-web ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 19 2015 21:43:13

###关闭selinux
[root@centos7-web ~]# setenforce 0

[root@centos7-web ~]# vim /etc/httpd/conf/httpd.conf

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

Alias /bbs "/forum/htdocs"

<Directory "/forum/htdocs">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Require all granted
</Directory>
上述别名的配置,就是说当你基于你的站点访问http://www.yourdoamin.com/bbs目录下的文件时,会直接从服务器/forum/htdocs目录下访问对应的文件。

[root@centos7-web ~]# systemctl reload httpd
[root@centos7-web ~]# mkdir -pv /forum/htdocs/
mkdir: created directory ‘/forum/htdocs/’
[root@centos7-web ~]# echo "This is a alias path test.">>/forum/htdocs/index.html

[root@centos7-web ~]# curl http://localhost/bbs/index.html
This is a alias path test.

如果alias路径中指定的尾部目录斜线,如下,应两者匹配
Alias /bbs/ "/forum/htdocs/"
<Directory "/forum/htdocs/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Require all granted
</Directory>

DBA牛鹏社(SQL/NOSQL/LINUX)

目录
相关文章
|
Linux 网络安全 Apache
CentOS 7.2配置Apache服务httpd(上)
CentOS 7.2配置Apache服务httpd(上)
944 1
|
存储 分布式计算 druid
大数据-152 Apache Druid 集群模式 配置启动【下篇】 超详细!(一)
大数据-152 Apache Druid 集群模式 配置启动【下篇】 超详细!(一)
311 1
大数据-152 Apache Druid 集群模式 配置启动【下篇】 超详细!(一)
|
缓存 前端开发 应用服务中间件
CORS跨域+Nginx配置、Apache配置
CORS跨域+Nginx配置、Apache配置
843 7
apache+tomcat配置多站点集群的方法
apache+tomcat配置多站点集群的方法
222 4
|
消息中间件 分布式计算 druid
大数据-152 Apache Druid 集群模式 配置启动【下篇】 超详细!(二)
大数据-152 Apache Druid 集群模式 配置启动【下篇】 超详细!(二)
195 2
|
负载均衡 应用服务中间件 Apache
Tomcat负载均衡原理详解及配置Apache2.2.22+Tomcat7
Tomcat负载均衡原理详解及配置Apache2.2.22+Tomcat7
316 3
|
存储 消息中间件 druid
大数据-151 Apache Druid 集群模式 配置启动【上篇】 超详细!
大数据-151 Apache Druid 集群模式 配置启动【上篇】 超详细!
314 1
|
Linux PHP Apache
CentOS 7.2配置Apache服务httpd(下)
CentOS 7.2配置Apache服务httpd(下)
292 1
|
存储 Apache 开发工具
apache的主要目录结构及常见的配置选项的详细说明(图例展示)
apache的主要目录结构及常见的配置选项的详细说明(图例展示)
533 1
|
6月前
|
人工智能 数据处理 API
阿里云、Ververica、Confluent 与 LinkedIn 携手推进流式创新,共筑基于 Apache Flink Agents 的智能体 AI 未来
Apache Flink Agents 是由阿里云、Ververica、Confluent 与 LinkedIn 联合推出的开源子项目,旨在基于 Flink 构建可扩展、事件驱动的生产级 AI 智能体框架,实现数据与智能的实时融合。
1122 6
阿里云、Ververica、Confluent 与 LinkedIn 携手推进流式创新,共筑基于 Apache Flink Agents 的智能体 AI 未来

推荐镜像

更多
下一篇
开通oss服务