【问题标题】:Custom redirect not working on the localhost自定义重定向在本地主机上不起作用
【发布时间】:2015-06-07 09:24:31
【问题描述】:

我在 Magento 根文件夹的 .htaccess 文件中创建了一个自定义重定向。 magento 的基本 url 是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。 如何解决?

【问题讨论】:

  • 您将文档根定义为什么?
  • @PanamaJack 我应该在哪里检查这个?
  • 在您的虚拟主机文件中。可能是httpd.conf。你设置了吗?
  • @PanamaJack 请查看更新后的问题
  • 如果它在 magento 文件夹中,请尝试将 RewriteBase 设置在您的规则之上。 RewriteBase /mymagento/

标签: .htaccess magento redirect url-rewriting xampp


【解决方案1】:

在进行了以下更改后,它对我有用。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-05
    • 2017-03-06
    • 2013-06-27
    • 1970-01-01
    • 1970-01-01
    • 2012-05-03
    相关资源
    最近更新 更多