【问题标题】:.htaccess redirect example.com/magento/index.php to example.com/?.htaccess 将 example.com/magento/index.php 重定向到 example.com/?
【发布时间】:2014-10-17 01:47:54
【问题描述】:

我在子目录中安装了 Magento,Magento 的路径是 example.com/magento

我在根目录中有一个.htaccess 文件,“example.com”,如下所示:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^magento/(.+)$ http://www.example.com/$1 [R=301,L] 
RewriteCond %{HTTP_HOST}   ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/magento(/.*)?$ [NC]
RewriteRule ^(.*)$         /magento/$1    [QSA,L]

example.com/magento 中的标准 Magento .htaccess 中,我取消了 RewriteBase 指令的注释,如下所示:

RewriteBase /magento/

但是当我输入example.com 时,浏览器显示example.com/magento

我该如何解决这个问题?

【问题讨论】:

  • 我认为应该是RewriteBase /,因为这个 .htaccess 在您网站的根目录中。除此之外,您的第一个条件/规则可能不匹配,因此不会重定向用户。
  • @Sumurai8,也许你是对的。但我是一个关于 .htaccess 配置的假人。如果你能帮我解决这个问题,我会很高兴。

标签: .htaccess magento mod-rewrite subdirectory


【解决方案1】:

留下 RewriteBase 的评论

# RewriteBase /magento/

改为在 /.htacccess 中试试这个:

RewriteEngine on
RewriteRule ^(.*)$ /magento/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [L]

并将其添加到您的 magento/.htaccess 中:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [L]
</IfModule>

【讨论】:

    猜你喜欢
    • 2011-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-21
    • 2019-01-27
    • 2018-07-05
    相关资源
    最近更新 更多