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

activate mod_rewrite How To Set Up mod_rewrite for Apache on Ubuntu 14.04 Apache Rewrite url重定向功能的简单配置的更多相关文章

  1. Ubuntu系统启用Apache Mod_rewrite模块

    在终端中执行 sudo a2enmod rewrite 指令后,即启用了 Mod_rewrite 模块. 另外,也可以通过将 /etc/apache2/mods-available/rewrite.l ...

  2. Debian/Ubuntu下安装Apache的Mod_Rewrite模块的步骤

    启用 Mod_rewrite 模块:sudo a2enmod rewrite 另外,也可以通过将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/a ...

  3. Debian/Ubuntu下安装Apache的Mod_Rewrite模块的步骤分享

    启用 Mod_rewrite 模块:sudo a2enmod rewrite 另外,也可以通过将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/a ...

  4. Drupal7配置简洁URL(Clear URL)

    参考:Apache Rewrite url重定向功能的简单配置 这两天折腾死了 首先说一下我的环境: Aache2.4.25-x64-vc14-r1;php-7.0.19-Win32-VC14-x64 ...

  5. apache url路由配置重写

    最近复习了一下Apache Rewrite url重定向功能,有个项目用到了.htaccess,简单的几行代码,是看不怎么明白,于是复习了一下. 1.Apache Rewrite的主要功能 就是实现U ...

  6. 让网站通过Https访问

    Prerequisites Before you begin, you should have some configuration already taken care of. We will be ...

  7. Docker - 在Ubuntu 14.04 Server上的安装Docker

    在 Ubuntu 14.04 Server 上安装过程是最简单的, 其满足了安装 Docker的所有要求,只需要执行如下安装脚本即可. 如果你有可能,请使用14.04版本的Ubuntu, 避免给自己挖 ...

  8. modsecurity配置指令学习

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

  9. Ubuntu下Apache+SVN+submin实现WEB管理SVN

    为什么需要submin管理SVN? 原来在Ubuntu下,都是直接通过命令行创建SVN仓库并分配权限,但是这有一些问题: 每创建一个SVN仓库,都需要修改httpd.conf 每创建一个帐户,都需要手 ...

随机推荐

  1. 从调试角度理解ActionContext、OgnlContext、OgnlValueStack的关系

    被调试代码:    package web; import java.util.Map; import javax.servlet.http.HttpServletRequest; import or ...

  2. Jquery 事件执行两次

    js(jquery)的on绑定点击事件执行两次的解决办法—不是事件绑定而是事件冒泡 阻止冒泡的方法并不止 return false 这一种,还有event.stopPropagation(),这两种方 ...

  3. CentOS minimal 版安装图形界面的步骤分享,中文语言包

    1.连接网络: CentOS minimal.iso安装好后,进入终端,默认是不开网络的, 首先启用网卡, 自动获取ip. ifconfig eth0 up dhclient eth0 这时候再 if ...

  4. [C++]文件头引入#ifndef与#define有什么作用

    相关资料:https://zhidao.baidu.com/question/15822506.html 在c.h文件中,a.h文件被包含了两次.而C++规定在同一文件中只能将同一个头文件包含一次.# ...

  5. WP架构设计(一)MVVM回顾

    [MVVM的定义]     MVVM的目的是什么? 简单总结起来一句话:分离UI逻辑和业务逻辑.这一点和被大家熟知的MVP和MVC是一致的.     下面详细来说明下这个问题,下面一段英文来自Msdn ...

  6. Spring MVC添加支持Http的delete、put请求!(HiddenHttpMethodFilter)

    浏览器form表单只支持GET与POST请求,而DELETE.PUT等method并不支持,spring3.0添加了一个过滤器,可以将这些请求转换为标准的http方法,使得支持GET.POST.PUT ...

  7. CSS——你所不知的 CSS ::before 和 ::after 伪元素用法(转)

    你所不知的 CSS ::before 和 ::after 伪元素用法 CSS 有两个说不上常用的伪类 :before 和 :after,偶尔会被人用来添加些自定义格式什么的,但是它们的功用不仅于此.前 ...

  8. mysql --mysqli::multi_query 和 mysqli_multi_query

    语法: 对象化:bool mysqli::multi_query ( string $query ) 过程化:bool mysqli_multi_query ( mysqli $link , stri ...

  9. 【BZOJ】1644: [Usaco2007 Oct]Obstacle Course 障碍训练课(bfs)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1644 这和原来一题用dp来做的bfs很像啊orz.. 我们设f[i][j][k]代表i,j这个点之前 ...

  10. tinycore remaster方法

    11.1. PrerequisitesYou need a Linux distribution with the required programs available:cpio, tar, gzi ...