.htaccess Rewrite apache重写和配置
2016-06-11 11:26
676 查看
首先: 必须要空间支持 Rewrite 以及对站点目录中有 .htaccess 的文件解析,才有效. 如何让空间支持Rewrite 和 .htaccess 的文件解析呢 往下看 第一步:要找到apache安装目录下的httpd.cof文件,在里面找到 <Directory /> Options FollowSymLinks AllowOverride none </Directory> 把none改all, 第二步:找到以下内容: #LoadModule rewrite_module modules/mod_rewrite.so 改为 LoadModule rewrite_module modules/mod_rewrite.so 第三步:保存重启apache。 ok。 其次是.htaccess的书写规则: .htaccess加入以下内容 RewriteEngine On RewriteBase / RewriteRule ^(.*)list-id([0-9]+)\.html$ $1/company/search.php?sectorid2=$2 RewriteRule ^(.*)cominfo-([a-z0-9]+)\.html$ $1/member/index.php?uid=$2&type=cominfo RewriteRule ^(.*)list-([0-9]+)-([0-9]+)\.html$ $1/plus/list.php?typeid=$2&PageNo=$3 RewriteCond %{HTTP_HOST} ^[a-z0-9\-]+\.lujin\.com$ RewriteCond %{HTTP_HOST} !^(www|bbs)\.lujin\.com$ RewriteRule ^/?$ /%{HTTP_HOST} RewriteRule ^/([a-z0-9\-]+)\.lujin\.com/?$ /member/index.php?uid=$1 [L] 对上面的一些解释 RewriteRule ^(.*)list-id([0-9]+)\.html$ $1/company/search.php?sectorid2=$2 这条是把企业库的分类进行伪静态处理 原先假设访问地址为http://www.xxx.com/company/search.php?sectorid2=1 现在地址为http://www.xxx.com/list-id1.html 优点:1、伪静态处理加速搜索引擎收入 2、地址映射到根目录,增加权重,提高排名 3、也不知道还有什么…… RewriteRule ^(.*)list-([0-9]+)-([0-9]+)\.html$ $1/plus/list.php?typeid=$2&PageNo=$3 这个是供求等分类的列表,和上面的原理类似,到页面相应修改即可 下面是会员空间的二级域名方案 前提是把域名设置好泛解析 RewriteCond %{HTTP_HOST} ^[a-z0-9\-]+\.lujin\.com$ RewriteCond %{HTTP_HOST} !^(www|bbs)\.lujin\.com$ RewriteRule ^/?$ /%{HTTP_HOST} RewriteRule ^/([a-z0-9\-]+)\.lujin\.com/?$ /member/index.php?uid=$1 [L] 假设原先的地址为http://www.xx.com/member/index.php?uid=admin 现在地址为http://admin.xx.com 你只要在你想出现的地方放上这个就可以,比如在列表页面可以用[field:writer/]获取用户名,那么就可以在列表页面直接链接会员空间,可以写成http://[field:writer/].xx.com
相关文章推荐
- ant安装使用指南
- Caused by: org.xml.sax.SAXParseException; systemId: file:/opt/apache-nutch-2.2.1/runtime/local/conf/
- 用eclips连hadoop报Unknown protocol to job tracker: org.apache.hadoop.hdfs.protocol.ClientProtoco
- apache+mysql+php实现最大负载的方法
- Ubuntu下Apache配置SSL笔记
- apache目录浏览
- Win7如何部署apache服务器(包括SSL设置)
- linux下SVN+apache搭建
- Mac 10.10.4下配置apache
- Ubuntu下搭建LAMP环境
- Apache+Python+Web例程
- apache服务器的安装与使用
- Apache 配置里面使用 Win32DisableAcceptEx ,Apache 启动不了
- windows下Apache 内存耗尽假死显现
- CentOS6.7上编译安装Apache2.2和Apache2.4
- 完美企业后台管理项目架构,apache shiro,bootstrap,spring,springMVC,mybatis,github,gradle
- 基于mysql的hive安装配置(apache-hive-2.0.1-bin.tar.gz)
- 安装apacheZeppelin
- Eclipse使用Maven创建普通Java工程时错误:Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.
- Win7本地运行apache+php, php响应缓慢-千古大坑