【问题标题】:.html files not accessible in Magento when added to root folder.html 文件添加到根文件夹时无法在 Magento 中访问
【发布时间】:2015-06-23 15:50:21
【问题描述】:

我正在运行一个 Magento 站点,需要将一个 google 站点所有权确认文件上传到根目录。当我这样做时,当输入如下 www.website.com/google0564e497cc4446t6.html 时,无法通过 url 访问 html 文件,而是得到一个 404 页面。其他文件格式工作得很好。我的结论是必须有一个 .htaccess 重定向。

这是 .htaccess 内容:

## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on
##  RewriteRule ^(.)ItemDesc.asp?IC=(.)$ $1$2 [L]
##  RewriteRule ^supply-items/$ ItemDesc.asp?IC= [NC,L]
RewriteRule ^([^/]*)\.html$ /ItemDesc.asp?IC=$1 [L]
##RewriteRule ^ItemDesc.asp?IC=$ supply-items/ [L,R=301]
RewriteRule test_rewrite\.html http://www.website.com/rewrite_successful.html [R=301,L]
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

事实证明,以前的网站重定向对于维护 SEO 非常重要,所以我不能只删除它们。但是,有没有办法使用 .htaccess 文件对特定的 .html 文件(例如 www.website.com/google0564e497cc4446t6.html)进行例外处理?

谢谢!

【问题讨论】:

    标签: .htaccess magento redirect


    【解决方案1】:

    您可以修改规则的第一部分并添加条件以跳过 google 文件。

    RewriteCond %{REQUEST_URI} !^/google(.*)\.html$
    RewriteRule ^([^/]*)\.html$ /ItemDesc.asp?IC=$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2013-04-07
      • 2016-12-15
      • 2018-12-04
      • 1970-01-01
      • 1970-01-01
      • 2014-02-17
      • 1970-01-01
      • 2011-01-30
      • 2012-09-22
      相关资源
      最近更新 更多