apache tomcat 伪静态 struts2 伪静态
如果没有用apache就需要下载urlrewritefilter包,这种方法所有的请求都会先转到UrlRewriteFilter类中进行处理,效率较低一般把伪静态放在apache中进行处理,步骤如下:
1.打开apache/conf/httpd.conf文件
找到如下行,将前面的注释符#删除
#LoadModule rewrite_module modules/mod_rewrite.so
变为
LoadModule rewrite_module modules/mod_rewrite.so
2. 搜索AllowOverride 找到如下行
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All 将All 改为 None(注意如果搜索httpd.conf文件,里面有多个AllowOverride关键字,要设置htdocs路径的那个)
3. 在apache/htdocs路径下添加.htaccess文件,文件内添加伪静态重写代码,如
RewriteEngine On
RewriteRule Location.html Location.action
RewriteRule ^(.*)ChangeCity-(+)\.html$ $1/ChangeCity.action?countyId=$2 RewriteRule ^(.*)list-(+)-(+)\.html$ $1/plus/list.php?typeid=$2&PageNo=$3
RewriteCond %{HTTP_HOST} ^+\.lujin\.com$
RewriteCond %{HTTP_HOST} !^(www|bbs)\.lujin\.com$
RewriteRule ^/?$ /%{HTTP_HOST} RewriteRule ^/(+)\.lujin\.com/?$ /member/index.php?uid=$1
页:
[1]