Home > php教程 > php手册 > body text

apache、伪静态与htaccess 二级域名

WBOY
Release: 2016-06-06 20:00:58
Original
1868 people have browsed it

开启apache的伪静态: 在apache配置文件中将LoadModule jk_module modules/mod_jk.so前面的注释#去掉,2.0版本以下的和这个方法略有不同,现在应该很少有人在用了吧。 现在这种情况是它支持了伪静态,但还没有开始支持.htaccess,如果你要用到的话,需要将Al

开启apache的伪静态:
在apache配置文件中将LoadModule jk_module modules/mod_jk.so前面的注释”#”去掉,2.0版本以下的和这个方法略有不同,现在应该很少有人在用了吧。

现在这种情况是它支持了伪静态,但还没有开始支持.htaccess,如果你要用到的话,需要将AllowOverride None 这一行中的 None 改为 All。(就这个东西折腾了我许久)。

首先:

必须要空间支持 Rewrite 以及对站点目录中有 .htaccess 的文件解析,才有效.

如何让空间支持Rewrite 和 .htaccess 的文件解析呢 往下看

第一步:要找到apache安装目录下的httpd.cof文件,在里面找到


    Options FollowSymLinks
    AllowOverride none

把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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!