奇宝库 > apache url重写(戴尔r740服务器配置)

apache url重写(戴尔r740服务器配置)

如何在Apache环境中配置重写规则

Apache重写规则环境中的URL静态化对于搜索引擎来说是一个有利的设置。通过URL statization,可以将原来的动态php页面转换成静态HTML页面。当然这里的统计化是伪静态的,目的只是为了增加搜索引擎的搜索量。Discuz,Comsenz旗下的产品!子网站/X-SPACE、ECShop、SupeV、UCHome等。都支持这个功能。当然,这个功能还需要服务器环境的支持。下面介绍如何在Apache服务器下配置URL静态的重写规则。

当然这里有两种情况,一种是独立的主机用户,这些用户拥有对主机的管理权限,配置起来比较方便。(注:此处使用Discuz!以6.1.0的重写规则为例,后面会列出其他产品的重写规则。

首先,确定您使用的是哪个版本的Apache,以及是否加载了mod_Rewrite模块。

Apache 1.x的用户应该检查conf/httpd.conf中是否存在以下两个代码:

load module Rewrite _ module lib exec/mod _ Rewrite . so

addmodulemod _ rewrite . c Apache 2 . x的用户请检查conf/httpd.conf中是否存在以下代码:

load module Rewrite _ module modules/mod _ Rewrite . so

如果存在,那么将下面的代码添加到配置文件中(通常是conf/httpd.conf)。此时请注意,如果网站是由VirtualHost定义的,则必须添加到虚拟主机配置中,即虚拟主机。如果在虚拟主机配置之外添加,它可能不可用。更改后重新启动Apache。

IfModule mod_Rewrite.c

重写引擎开启

重写者^(.*)/archiver/((fid|tid)-[\w\-] \。html)$ $1/archiver/index.php?$2

重写者^(.*)/forum-([0-9] )-([0-9] )\html$ $1/forumdisplay.php?fid=$2page=$3

重写者^(.*)/thread-([0-9])-([0-9])-([0-9])\html$ $1/viewthread.php?tid=$2extra=page\=$4page=$3

重写者^(.*)/space-(用户名|uid)-(。)\.html$ $1/space.php?$2=$3

重写者^(.*)/tag-(。)\.html$ $1/tag.php?name=$2

/IfModule如果没有安装mod_Rewrite,可以重新编译Apache,将-enable-rewrite=shared添加到原来的configure内容中,然后将上述代码添加到Apache配置文件中。

另一种用户是Apache虚拟主机用户。

在开始下列设置之前,请咨询您的空间服务提供商,以了解空间是否支持的重写和文件解析。网站目录中的htaccess。否则,即使按照下面的方法设置,也不会使用。

检查。htaccess文件存在于论坛所在的目录中,如果没有,请手动创建该文件。在Win32系统下。无法直接创建htaccess文件。你可以从其他系统复制,或者从Discuz.net技术支持专栏下载。编辑和修改。htaccess文件添加以下内容:

#打开重写引擎模式

重写引擎开启

#修改/讨论下面的语句作为你的论坛目录地址。如果程序放在根目录下,请将/discussion修改为/

重写库/光盘

#不应修改重写系统规则。

^archiver/((fid|tid)-[\w\-] \。html)$ archiver/index.php?$1

^forum-([0-9] )-([0-9])。html $ forumdisplay.php?fid=$1page=$2

^thread-([0-9] )-([0-9] )-([0-9])。html $ viewthread.php?tid=$1extra=page\=$3page=$2

重写者^space-(username|uid)-(.)\.html $ space.php?$1=$2

重写者^tag-(.)\.html $ tag.php?Name=$1添加内容时,请按照上面的提示,修改论坛所在的路径,然后保存。上传。htaccess文件到论坛所在的目录。然后进入论坛系统设置的搜索引擎优化,根据需要开启URL静态功能。

下面是其他产品的一些重写规则。

子网站/X-SPACE 6.0 UC规则

Apache独立主机用户:

IfModule mod_Rewrite.c

重写引擎开启

# # #不应修改重写系统规则。

重写器^/([0-9])/空间列表(。)$ /index.php?uid/$ 1/操作/空间列表/类型$2 [L]

^/([0-9])/视图空间(。)$ /index.php?uid/$ 1/操作/视图空间/itemid$2 [L]

重写者^/([0-9])/观点论坛(。)$ /index.php?uid/$1/action/viewbbs/tid$2 [L]

^/([0-9]/(。*)$ /index.php?uid/$1/$2 [L]

重写者^/([0-9] )$ /index.php?uid/$1 [L]

重写者^/action(.)$ /index.php?操作1美元[升]

重写者^/category(.)$ /index.php?操作/类别/catid$1 [L]

重写者^/viewnews(.)$ /index.php?操作/查看新闻/itemid$1 [L]

重写者^/viewthread(.)$ /index.php?action/viewthread/tid$1 [L]

重写者^/mygroup(.)$ /index.php?action/mygroup/gid$1 [L]

/IfModuleApache虚拟主机用户:

### 将重写引擎模式打开

重写引擎开启

### 修改以下语句中的/SupeSite修改为你的苏佩斯特目录地址,如果程序放在根目录中,请将/SupeSite修改为/

重写库/

###重写系统规则请勿修改

重写器^([0-9])/空间列表(。)$ index.php?uid/$ 1/操作/空间列表/类型两美元

^([0-9])/视图空间(。)$ index.php?uid/$ 1/操作/视图空间/itemid$2 [L]

重写者^([0-9])/观点论坛(。)$ index.php?uid/$1/action/viewbbs/tid$2 [L]

^([0-9]/(。*)$ index.php?uid/$1/$2 [L]

index.php,$ ^([0-9?uid/$1 [L]

重写者^action(.)$ index.php?操作1美元[升]

重写者^category(.)$ index.php?操作/类别/catid$1 [L]

重写者^viewnews(.)$ index.php?操作/查看新闻/itemid$1 [L]

重写者^viewthread(.)$ index.php?action/viewthread/tid$1 [L]

重写者^mygroup(.)$ index.php?action/my group/GID $ 1[L]ecshop 2。6 .0规则

街头流氓独立主机用户:

IfModule mod_Rewrite.c

重写引擎开启

重写者^(.*)/index.html$ $1/index.php

重写者^(.*)/category$ $1/index.php [L]

重写者^(.*)/feed-c([0-9]).xml$ $1/feed.php?卡特彼勒=2美元[升]

重写者^(.*)/feed-b([0-9]).xml$ $1/feed.php?brand=$2 [L]

重写者^(.*)/feed.xml$ $1/feed.php

重写者^(.*)/category-([0-9])-b([0-9])-min([0-9])-max([0-9])-attr([^-]*)-([0-9))-(。)-(【a-zA-Z】)(.*)\.html$ $1/category.php?id=$ 2 brand=$ 3 price _ min=$ 4 price _ max=$ 5 filter _ attr=$ 6 page=$ 7 sort=$ 8 order=$ 9

重写者^(.*)/category-([0-9])-b([0-9])-min([0-9])-max([0-9])-attr([^-]*)\.html$ $1/category.php?id=$ 2 brand=$ 3 price _ min=$ 4 price _ max=$ 5 filter _ attr=$ 6

重写者^(.*)/category-([0-9])-b([0-9])-([0-9])-(.)-(【a-zA-Z】)(.*)\.html$ $1/category.php?id=$ 2品牌=$ 3页面=$ 4排序=$ 5订单=$ 6

重写者^(.*)/category-([0-9])-b([0-9])-([0-9]).*)\.html$ $1/category.php?id=$2brand=$3page=$4

重写者^(.*)/category-([0-9] )-b([0-9]).*)\.html$ $1/category.php?id=$2brand=$3

重写者^(.*)/category-([0-9]).*)\.html$ $1/category.php?id=$2

重写者^(.*)/商品-([0-9])(。*)\.html$ $1/goods.php?id=$2

重写者^(.*)/article _ cat-([0-9])-([0-9])-(.)-(【a-zA-Z】)(.*)\.html$ $1/article_cat.php?id=$2page=$3sort=$4order=$5

重写者^(.*)/article_cat-([0-9] )-([0-9]).*)\.html$ $1/article_cat.php?id=$2page=$3

重写者^(.*)/article_cat-([0-9])( .*)\.html$ $1/article_cat.php?id=$2

重写者^(.*)/article-([0-9])*)\.html$ $1/article.php?id=$2

重写者^(.*)/brand-([0-9])-c([0-9])-([0-9])-(.)-([a-zA-Z] )\html $1/brand.php?id=$ 2 cat=$ 3 page=$ 4 sort=$ 5 order=$ 6

重写者^(.*)/brand-([0-9])-c([0-9])-([0-9]).*)\.html $1/brand.php?id=$2cat=$3page=$4

重写者^(.*)/brand-([0-9] )-c([0-9]).*)\.html $1/brand.php?id=$2cat=$3

重写者^(.*)/brand-([0-9])*)\.html $1/brand.php?id=$2

重写者^(.*)/tag-(.*)\.html $1/search.php?关键词=$2

重写者^(.*)/snatch-([0-9])\ html $ $ 1/snatch . PHP?id=$2

重写者^(.*)/group _ buy-([0-9])\ html $ $ 1/group _ buy . PHP?act=viewid=$2

/IfModule

街头流氓虚拟主机用户:

重写引擎开启

#重写库/

#直接单字访问

重写者^index\.html$ index\ .php [L]

重写^category$指数php [L]

#通过数字标识符访问任何对象

^feed-c([0-9。xml$ feed\php\?卡特彼勒=$1 [L]

^feed-b([0-9。xml$ fe

本文来自网络,不代表本站立场,转载请注明出处: