ECShop 网上商店系统支持论坛's Archiver

prettyqj 发表于 2008-9-27 11:40

虚拟空间URL重写问题!

我的虚拟空间[table][tr][td=1,1,20%]Web 服务器:[/td][td]Apache/1.3.33 (Unix)[/td][/tr][/table]
不知道以下操作该如何进行,请知道的指教下。先谢谢了。。。。


*******************************************************************************
* 一、Apache 服务器
*******************************************************************************
   1、首先您需要找到 Apache 安装目录,之后找到 conf 目录下的 httpd.conf 文件。
   2、将下面的代码复制到 httpd.conf 文件中,注意将 /ecshop 替换为您的商店的实际
   安装目录。
<Directory /ecshop>
    Options FollowSymLinks
    AllowOverride All
</Directory>
   3、在 httpd.conf 中搜索 LoadModule rewrite_module,将该行前面的 # 号删除。
      如果您的 Apache 是1.3.x版本还需要查找 AddModule mod_rewrite.c,
      请将前面的#删除。
   4、保存 httpd.conf。
   5、将 ecshop 目录下的 htaccess.txt 重命名为 .htaccess。
   6、重新启动 Apache。
   7、进入 ecshop 管理中心->商店设置,将 URL 重写设置为启用。
   如果您想通过 httpd.conf 来设置重写规则,请按照下面的步骤操作:
   1、执行上面第1-3步操作。
   2、找到您的商店所在的虚拟主机段,如:
<VirtualHost 127.0.0.1>
     DocumentRoot "/home/ecshop/"
     ServerName [url=http://www.ecshop.com]www.ecshop.com[/url]
</VirtualHost>
   3、将下面的内容加入在</VirtualHost>之前
    <IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/index.html$                $1/index.php                     
RewriteRule ^(.*)/category$                  $1/index.php                       [L]
RewriteRule ^(.*)/feed-c([0-9]+).xml$        $1/feed.php?cat=$2                 [L]
RewriteRule ^(.*)/feed-b([0-9]+).xml$        $1/feed.php?brand=$2               [L]
RewriteRule ^(.*)/feed.xml$                  $1/feed.php
RewriteRule ^(.*)/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
RewriteRule ^(.*)/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
RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$                          $1/category.php?id=$2&brand=$3&page=$4&sort=$5&order=$6
RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$                            $1/category.php?id=$2&brand=$3&page=$4
RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)(.*)\.html$                             $1/category.php?id=$2&brand=$3
RewriteRule ^(.*)/category-([0-9]+)(.*)\.html$                              $1/category.php?id=$2
RewriteRule ^(.*)/goods-([0-9]+)(.*)\.html$                                  $1/goods.php?id=$2
RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  $1/article_cat.php?id=$2&page=$3&sort=$4&order=$5
RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)(.*)\.html$                   $1/article_cat.php?id=$2&page=$3
RewriteRule ^(.*)/article_cat-([0-9]+)(.*)\.html$                            $1/article_cat.php?id=$2
RewriteRule ^(.*)/article-([0-9]+)(.*)\.html$                                $1/article.php?id=$2
RewriteRule ^(.*)/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
RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html                $1/brand.php?id=$2&cat=$3&page=$4
RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)(.*)\.html                         $1/brand.php?id=$2&cat=$3
RewriteRule ^(.*)/brand-([0-9]+)(.*)\.html                                   $1/brand.php?id=$2
RewriteRule ^(.*)/tag-(.*)\.html                                             $1/search.php?keywords=$2
RewriteRule ^(.*)/snatch-([0-9])\.html$                                      $1/snatch.php?id=$2
RewriteRule ^(.*)/group_buy-([0-9])\.html$                                   $1/group_buy.php?act=view&id=$2
    RewriteRule ^(.*)/auction-([0-9]+)\.html$                                    $1/auction.php?act=view&id=$2
    </IfModule>

[[i] 本帖最后由 prettyqj 于 2008-9-27 16:33 编辑 [/i]]

Goda 发表于 2008-9-27 13:06

您现在需要做的是咨询空间商,是否支持rewrite重写,如果支持的话,您仅操作这步就可以了
5、将 ecshop 目录下的 htaccess.txt 重命名为 .htaccess。

prettyqj 发表于 2008-9-27 14:10

:'( :'( 。。为什么我操作后网站都打不开了。。。

Goda 发表于 2008-9-27 15:52

您可以参考这个帖子:
[url=http://bbs.ecshop.com/viewthread.php?tid=40279&highlight=%C4%E3%CD%F8%D5%BE%C4%BF%C2%BC%3A%2B%2Faa%2Fbb]http://bbs.ecshop.com/viewthread.php?tid=40279&highlight=%C4%E3%CD%F8%D5%BE%C4%BF%C2%BC%3A%2B%2Faa%2Fbb[/url]

[color=#000000]以下假设:[/color]
[color=#000000][/color]
[color=#000000]根目录: /aa[/color]
[color=#000000]你网站目录: /aa/bb[/color]
[color=#000000][/color]
[color=black]一,如果你是架设的虚拟主机[/color]
[color=#000000][/color]
[color=#ff0000][color=black]你可能是这样访问你的站点的:[/color] [url=http://xxx.com]http://xxx.com[/url] [/color]
[color=black][/color]
[color=black]你的网站目录可能需要如下规则(httpd.conf)[/color]
[color=black][/color]
[color=red]<Directory /aa/bb>
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>[/color]
[color=black][/color]
[color=black]不过为安全性考量[/color] [color=#ff0000]AllowOverride All [/color][color=black]你不必设置为All. 参考如下:[/color]
[color=#000000]All: 全部权限可重写[/color]
[color=#000000]AuthConfig: 网页验证权限可重写[/color]
[color=#000000]Indexes: Indexes重写[/color]
[color=#000000]Limits: 允许Order Allow,Deny管理权限的重写[/color]
[color=#000000]None: 不可重写[/color]
[color=#000000][/color]
[color=#000000]所以,当你的目录下的规则的 [/color][color=#ff0000]AllowOverride [/color][color=black]设为 [/color][color=red]None [/color][color=black]时,你网站目录下官方提供的 .htaccess 是不起作用的. 如果你开始不熟悉,建议设为 All 好了.不过你可能要经过你的虚拟主机提供方系统管理人员的同意.[/color]
[color=#000000][/color]
[color=#000000]其实, 在 httpd.conf 里, 有段对 DocumentRoot 的目录规则:[/color]
[color=#000000][/color]
[color=olive]DocumentRoot /aa[/color]
[color=olive][/color]
[color=olive]<Directory /aa>
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # [/color][url=http://httpd.apache.org/docs/2.2/mod/core.html#options][color=olive]http://httpd.apache.org/docs/2.2/mod/core.html#options[/color][/url]
[color=olive]    # for more information.
    #
    Options Indexes FollowSymLinks[/color]
[color=olive]    #
    # 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
    #
    [/color][color=red]AllowOverride None[/color]
[color=olive]    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all[/color]
[color=olive]</Directory>[/color]
[color=#808000][/color]
[color=black]如果你的网站目录在 /aa 目录下 , 你可以直接把上面红色的 设为 All .那么,我一开始说的那个 "你可能需要如下规则" 的那块就可以不需要了,因为/aa 目录下的AllOverride会被继承到 /aa/bb 目录.[/color]

[color=black]因为你的是虚拟主机,因此肯定会有你的主机配置:[/color]
[color=#000000][/color]
[color=red]<VirtualHost *:80>[/color]
[color=red]ServerAdmin [/color][email=XXX@XXX.com][color=red]XXX@XXX.com[/color][/email]
[color=red]DocumentRoot /aa/bb[/color]
[color=red]ServerName xxx.com
</VirtualHost>[/color]
[color=#ff0000][/color]
[color=#ff0000][color=black]你可能是这样访问你的站点的:[/color] [url=http://xxx.com]http://xxx.com[/url] [/color]
[color=#ff0000][color=black]看到[/color] [color=red]DocumentRoot /aa/bb [/color][color=black]这句了吗?[/color][/color]
[color=#ff0000][color=#000000]在官方提供的 .htaccess 文件里有这句: [/color][color=red]RewriteBase / , [/color][color=black]呵,它在虚拟主机里这样写是对的,因为虚拟主机配置规则里声明了 DocumentRoot了, [/color][/color][color=red][b]因此在 .htaccess 文件里用 / 代替网站目录.而这里,正是许多在本机配置url重写不成功的原因.[/b][/color]
[color=#ff0000][color=#000000][/color][/color]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.