---
title: "apache httpd mod_rewrite"
author: "vanghoh"
date: "2012-06-01T15:36:05Z"
tags: []
categories: ["非技术"]
slug: "apache-httpd-mod-rewrite"
draft: false
lastmod: "2012-06-01T15:36:05Z"
id: 1546588
url: "https://vanghoh.iteye.com/blog/1546588"
---

**安装：**

**1.如果为初次安装apache，在编译时增加--enable-rewrite选项。** 

./configure --prefix=/usr/local/apachel --enable-so --enable-mods-shared=all --enable-rewrite --enable-cache 

**2.如果已安装apahe httpd，但通过./apachectl -l发现未安装mod\_rewrite，增加mod\_rewrite模块方法：**

\# 在apache的**源码安装目录**中寻找mod\_rewrite.c文件 

find . -name mod\_rewrite.c

\# 进入包含mod\_rewrite.c文件的目录 

cd PATH/to/mod\_rewrite.c

\# 完成后apache的modules目录中会有mod\_rewrite.so文件。 

/usr/local/apache/bin/apxs -c mod\_rewrite.c 

/usr/local/apache/bin/apxs -i -a -n mod\_rewrite mod\_rewrite.la 

 

 

\# 编辑httpd.conf文件，加入： 

LoadModule rewrite\_module modules/mod\_rewrite.so