Apache+Tomcat实现UrlRewrite

1、安装jdk,tomcat和apache
测试apache是否安装成功?
在地址栏输入:http://localhost/,显示结果为 it works

2、下载mod_jk.dll,改后缀so
PS:为了将Apache和Tomcat服务器进行整合,您还需要安装mod_jk.so组件
将mod_jk.so放入C:\Program Files\Apache Software Foundation\Apache2.2\modules

3、在C:\Program Files\Apache Software Foundation\Apache2.2\conf下新增workers.properties文件,内容如下:
引用
workers.tomcat_home=C:\tomcat 6
workers.java_home=C:\Program Files\Java\jdk1.6.0_10
ps=\
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1


4、在httpd.conf最后添加如下语句:
引用
LoadModule jk_module modules/mod_jk.so
JkWorkersFile "conf/workers.properties"
JkLogFile "logs/mod_jk2.log"
JkLogLevel info
#<VirtualHost *:80> 
ServerAdmin chenlin.ctoall.com
DocumentRoot "D:\workspace\repos\shop_F\branches\shop_20091223\shop-web-F\target\shopF"
ServerName localhost
DirectoryIndex index.html
ErrorLog logs/shsc-error_log.txt
CustomLog logs/shsc-access_log.txt common
#JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
JkMount /*.do ajp13
JkMount /*.action ajp13
JkMount /*.html ajp13
JkMount /* ajp13
<Directory "D:\workspace\repos\shop_F\branches\shop_20091223\shop-web-F\target\shopF">
Options Indexes
AllowOverride all
Order allow,deny
Allow from all
</Directory>


5、Apache开启Mod_rewrite模块
一 打开Apache2\conf\httpd.conf
(1).搜索 LoadModule rewrite_module modules/mod_rewrite.so (Apache2是这个),去掉前面的#
(2).搜索 AllowOverride None 替换为 AllowOverride All

二 在Apache2\conf\httpd.conf 最后一行添加:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule 改写的静态url 实际url [PT]
</IfModule>
eg:RewriteRule ^(.*)/displaydetail_([0-9]+)\.html $1/displaydetail.html?itemId=$2 [PT]

三 重启Apache
登陆PW后台开启全伪
PS:不需要定义.htaccess文件

你可能感兴趣的:(apache,tomcat,C++,c,C#)