自定义重定向不在localhost上工作

时间:2015-04-02 12:12:07

标签: .htaccess magento redirect url-rewriting xampp

我在Magento根文件夹的.htaccess文件中创建了自定义重定向。 magento的基本网址为http://127.0.0.1/mymagento/

## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

    RewriteRule ^kit-rasage.html    /spray-can.html [R=301,L]

但是当我访问http://127.0.0.1/mymagento/kit-rasage.html时,它会重定向到http://127.0.0.1/kit-rasage.html

文档根目录如httpdconf文件

中所示
<Directory "C:/xampp/htdocs">
#
# 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
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI

#
# 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

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

操作系统是Windows 7,我正在使用XAMPP。 如何解决?

1 个答案:

答案 0 :(得分:0)

经过以下更改后,它对我有用。

RewriteBase /mymagento/
RewriteRule ^kit-rasage.html    /spray-can.html [R=301,L]

在本地主机上,我们在htdocs文件夹中有其他目录,因此我们必须添加RewriteBase /mymagento/,其中mymagento是目录名。