看了好几遍,还是不太清楚.先记下了,有空再看看.apache发展了这么多年,我也用了这么久,就这样一个指令,会用但是不完全了解实际的含义.

RewriteBase Directive

Description: Sets the base URL for per-directory rewrites
Syntax: RewriteBase URL-path
Default: See usage for information.
Context: directory, .htaccess
Override: FileInfo
Status: Extension
Module: mod_rewrite

The RewriteBase directive explicitly sets the base URL for per-directory rewrites. As you will see below, RewriteRule can be used in per-directory config files (.htaccess). In such a case, it will act locally, stripping the local directory prefix before processing, and applying rewrite rules only to the remainder. When processing is complete, the prefix is automatically added back to the path. The default setting is; RewriteBase physical-directory-path

When a substitution occurs for a new URL, this module has to re-inject the URL into the server processing. To be able to do this it needs to know what the corresponding URL-prefix or URL-base is. By default this prefix is the corresponding filepath itself. However, for most websites, URLs are NOT directly related to physical filename paths, so this assumption will often be wrong! Therefore, you can use the RewriteBase directive to specify the correct URL-prefix.

If your webserver's URLs are not directly related to physical file paths, you will need to use RewriteBase in every .htaccess file where you want to use RewriteRule directives.

For example, assume the following per-directory config file:

#
#  /abc/def/.htaccess -- per-dir config file for directory /abc/def
#  Remember: /abc/def is the physical path of /xyz, i.e., the server
#            has a 'Alias /xyz /abc/def' directive e.g.
#
RewriteEngine On
#  let the server know that we were reached via /xyz and not
#  via the physical path prefix /abc/def
RewriteBase   /xyz
#  now the rewriting rules
RewriteRule   ^oldstuff/.html$  newstuff.html

In the above example, a request to /xyz/oldstuff.html gets correctly rewritten to the physical file /abc/def/newstuff.html.

For Apache Hackers

The following list gives detailed information about the internal processing steps:

Request:
/xyz/oldstuff.html
Internal Processing:
/xyz/oldstuff.html     -> /abc/def/oldstuff.html  (per-server Alias)
/abc/def/oldstuff.html -> /abc/def/newstuff.html  (per-dir    RewriteRule)
/abc/def/newstuff.html -> /xyz/newstuff.html      (per-dir    RewriteBase)
/xyz/newstuff.html     -> /abc/def/newstuff.html  (per-server Alias)
Result:
/abc/def/newstuff.html

This seems very complicated, but is in fact correct Apache internal processing. Because the per-directory rewriting comes late in the process, the rewritten request has to be re-injected into the Apache kernel. This is not the serious overhead it may seem to be - this re-injection is completely internal to the Apache server (and the same procedure is used by many other operations within Apache).

apache - mod_rewrite配置指令RewriteBase相关推荐

  1. apache配置指令速查

    AcceptFilter AcceptFilter 指令 说明 根据协议类型对监听Socket进行优化 语法 AcceptFilter protocol accept_filter 作用域 serve ...

  2. 关于Apache mod_rewrite的中文配置、使用和语法介绍(实现URL重写和防盗链功能)

    介绍和配置: 以数据库后台驱动的动态内容的网站,经常会遇到这些的问题: 当在浏览器的地址栏输入一个无效的参数时,会出现数据库的错误提示,这是一个安全的隐患 搜索引擎无法收录你的所有网页 网页的链接地址 ...

  3. modsecurity配置指令学习

    事务(transactions) Console(控制台) 1 Introduction Modsecurity是保护网络应用安全的工作.不,从零开始.我常称modsecurity为WAF(网络应用防 ...

  4. Apache常见配置及问题

    1.Apache的配置由httpd.conf文件配置修改. 主站点的配置(基本配置) (1) 基本配置: ServerRoot "/mnt/software/apache2" #你 ...

  5. Linux下apache性能配置调优

    Apache 性能配置优化 ###httpd 相关查看命令了解 查看当前安装模块mpm(多路处理器) [root@localhost ~]# httpd -l 查看httpd进程数(即各个mpm模式下 ...

  6. apache性能配置优化

    最近在进行apache性能优化设置.在修改apache配置文件之前需要备份原有的配置文件夹conf,这是网站架设的好习惯.以下的apache配置调优均是在red had的环境下进行的. httpd相关 ...

  7. 九爷带你了解 nginx 日志配置指令详解

    nginx日志配置指令详解 日志对于统计排错来说非常有利的. 本文总结了nginx日志相关的配置如 access_log.log_format.open_log_file_cache.log_not_ ...

  8. apache虚拟机配置步骤和修改访问端口

    这篇文章主要介绍了apache虚拟机配置步骤和修改访问端口的方法(虚拟机端口映射),需要的朋友可以参考下 一.添加服务端口 在文件Apache\conf\httpd.conf中, 1.找到 Liste ...

  9. Apache 2配置域名绑定的步骤

    这篇文章主要给大家介绍了Apache 2配置域名绑定的方法,文中介绍的很详细,需要的朋友可以参考借鉴,下面来一起看看吧. 前言 最近新装了个OJ系统,想着总是用ip访问挺难记得,就打算绑一个域名上去. ...

  10. 开启Apache mod_rewrite模块(解决404 Not Found)

    网站搭建完成了,进入登录界面就是访问不了. 原因大概是没有开启Apache mod_rewrite模块,或者没有配置完全. 步骤1: 启用mod_rewrite模块 在conf目录的httpd.con ...

最新文章

  1. Eclipse 最常用的 10 组快捷键,个个牛逼!
  2. OpenGL 帧缓冲区
  3. mysql事务隔离级别 花_MySQL事务的隔离级别
  4. redis 实际应用中的缓存作用
  5. 如何写一个能被手机打开的C语言小程序,如何用C语言中一些简单的语句做一个小程序,能够输入一个字符就会弹出一句话...
  6. JZOJ 5669. 【GDSOI2018模拟4.19】排列
  7. 白领丽人:这六行盛产“钻石王老五”
  8. 苹果发布 macOS 12——Monterey
  9. linux内核那些事之物理内存模型之SPARSE(3)
  10. SAP License:BCS进阶第一篇-BCS相关概念
  11. java 静态成员 实例成员变量_java对象实例化时的顺序(静态成员变量、静态代码块、成员变量、方法块加载、构造函数加载)...
  12. Longest Common Substring($LCS$)
  13. 制版经验分享—使用AD18
  14. 如何制作一个读取U盘文件系统的工程
  15. 车载视频监控怎么安装?《M51H车载及摄像机安装指导》
  16. excel换行快捷键_excel换行快捷键 Excel表格中怎么换行 | 优词网
  17. 防火墙的策略路由PBR
  18. VBOX虚拟机的网络设置
  19. c语言factors函数的意思,factors是什么意思_factors的翻译_音标_读音_用法_例句_爱词霸在线词典...
  20. 【Linux】虚拟机VMware的Ubuntu使用vi指令的方向键和backspace空格键乱码

热门文章

  1. 这位成功转型机器学习的老炮,想把他多年的经验分享给你
  2. SDUT——2021级-JAVA02 基础语法1--标识符、常量与变量、数据类型、运算符与表达式
  3. 基于中科院-CASIA-GaitDatasetB步态图像轮廓数据库的步态周期检测与步态角度特征MATLAB源码介绍
  4. Android实现模拟装备购买
  5. 浅谈“Robots文件信息泄露”
  6. TBODY标签的作用介绍
  7. python游戏书籍推荐_有什么好的自学 Python 的书籍推荐?
  8. 25 岁的 Linux 已经无处不在,它是如何毁了微软统治世界的计划?
  9. 物联网产品的发展简介(二)【产品篇02】
  10. c++做的免费游戏狼人杀