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. python 获取当前时间的用法

    1.先导入库:import datetime 2.获取当前日期和时间:now_time = datetime.datetime.now() 3.格式化成我们想要的日期:strftime() 比如:“2 ...

  2. Hadoop HDFS操作命令总结

    Hadoop HDFS操作命令总结 1.列出根目录下所有的目录或文件 hadoop fs -ls / 2.列出/logs目录下的所有目录和文件 hadoop fs -ls /logs 3.列出/use ...

  3. Vs code 通用插件

    Vs code 通用插件 转自:https://segmentfault.com/a/1190000006697219 HTML Snippets 超级实用且初级的 H5代码片段以及提示 HTML C ...

  4. Linux(Ubuntu/Debian/CentOS/RedHat)下交叉编译boost库

    我用的软件版本如下(其他版本编译方法与此完全相同): Boost Ver: 1.55.0Compiler : GNU gcc 4.6 for ARM 1. 确保ARM编译成功安装,并配置好环境变量.2 ...

  5. jquery设置radio选中

    <script type="text/javascript"> $(document).ready(function(){ $("input[type=rad ...

  6. msyql的内存计算

    本文将讨论MySQL内存相关的一些选项,包括: 单位都是b,不是kb,即1B=1/(1024*1024*1024)G 1)全局的buffer,如innodb_buffer_pool_size: 2)线 ...

  7. 记一次线上Kafka消息堆积踩坑总结

    2018年05月31日 13:26:59 xiaoguozi0218 阅读数:2018更多 个人分类: 大数据   年后上线的系统,与其他业务系统的通信方式采用了第三代消息系统中间件Kafka.由于是 ...

  8. PHP多进程编程(3):多进程抓取网页的演示

    我们知道,从父进程到子经常的数据传递相对比较容易一些,但是从子进程传递到父进程就比较的困难. 有很多办法实现进程交互,在php中比较方便的是 管道通信.当然,还可以通过 socket_pair 进行通 ...

  9. C++ 匿名对象的生命周期

    //匿名对象的生命周期 #define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; class Poin ...

  10. 浅析 Hadoop 中的数据倾斜

    转自:http://my.oschina.net/leejun2005/blog/100922 最近几次被问到关于数据倾斜的问题,这里找了些资料也结合一些自己的理解. 在并行计算中我们总希望分配的每一 ...