https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04

 ubuntu@ubuntu:~$ su
Password:
root@ubuntu:/home/ubuntu# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
root@ubuntu:/home/ubuntu# service apache2 restart

https://httpd.apache.org/docs/2.4/en/rewrite/

将任意的url 映射为服务器内部的url结构

mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules. This allows you to map arbitrary URLs onto your internal URL structure in any way you like.

It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests: server variables, environment variables, HTTP headers, time stamps, external database lookups, and various other external programs or handlers, can be used to achieve granular URL matching.

Rewrite rules can operate on the full URLs, including the path-info and query string portions, and may be used in per-server context (httpd.conf), per-virtualhost context (<VirtualHost> blocks), or per-directory context (.htaccess files and <Directory> blocks). The rewritten result can lead to further rules, internal sub-processing, external request redirection, or proxy passthrough, depending on what flags you attach to the rules.

Since mod_rewrite is so powerful, it can indeed be rather complex. This document supplements the reference documentation, and attempts to allay some of that complexity, and provide highly annotated examples of common scenarios that you may handle with mod_rewrite. But we also attempt to show you when you should not use mod_rewrite, and use other standard Apache features instead, thus avoiding this unnecessary complexity.

Character Meaning Example
. Matches any single character c.t will match catcotcut, etc.
+ Repeats the previous match one or more times a+ matches aaaaaa, etc
* Repeats the previous match zero or more times. a* matches all the same things a+ matches, but will also match an empty string.
? Makes the match optional. colou?r will match color and colour.
^ Called an anchor, matches the beginning of the string ^a matches a string that begins with a
$ The other anchor, this matches the end of the string. a$ matches a string that ends with a.
( ) Groups several characters into a single unit, and captures a match for use in a backreference. (ab)+ matches ababab - that is, the + applies to the group. For more on backreferences see below.
[ ] A character class - matches one of the characters c[uoa]t matches cutcot or cat.
[^ ] Negative character class - matches any character not specified c[^/]t matches cat or c=t but not c/t

最新文章

  1. unity 3d 解析 json
  2. fasicon.js (无二维码版,如需要js创建二维码版本可联系我:770959294@qq.com)
  3. html form 提交表单的一些问题
  4. Java获取当前时间年月日、时间格式化打印、字符串转日期
  5. VPS CentOS-6 下 LNMP HTTP服务器的搭建
  6. java之多态(Polymorphic)、动态绑定(Dynamic Binding)、迟绑定(Late Binding)
  7. bianwu | 数据行 | 填写意见
  8. Spring MVC 之类型转换(五)
  9. 读取excel文件内容代码
  10. hdu2023 求平均成绩 ~~很闲~~~
  11. Asp.net中基于Forms验证的角色验证授权
  12. 用java面向对象的思想实现的汉诺塔问题
  13. MySQL percona-toolkit工具包的使用教程
  14. Git----GitHub Desktop的入门及使用
  15. Fiddler-弱网测试设置
  16. 【JS基础】类型转换——不同数据类型比较
  17. beego 实现API自动化文档
  18. VMware Workstation Pro 14 虚拟机安装教程
  19. 《汇编语言 基于x86处理器》第九章字符串与数组部分的代码
  20. visual studio使用GitHub

热门文章

  1. Java线程中断理解(interrupte)
  2. 示例 Demo 工程和 API 参考链接
  3. Centos7上修改mysql数据目录
  4. C++-教程3-VS2010C++各种后缀说明
  5. [I2C]pca9555应用层测试代码
  6. devicetree -- SPI
  7. shell 后台执行脚本
  8. Spark的操作列表
  9. 手把手教你利用微软的Bot Framework,LUIS,QnA Maker做一个简单的对话机器人
  10. 【BZOJ】1627: [Usaco2007 Dec]穿越泥地(bfs)