magento 网站迁移后产品图片不显示

发布于 2024-09-13 07:50:41 字数 1073 浏览 5 评论 0 原文

我最近将我的 magento 网站迁移到另一台服务器,这是我使用的过程:

  1. 转储数据库。
  2. 将所有系统文件从 FTP 复制到我的硬盘上。
  3. 清空 VAR 文件夹
  4. 清空媒体缓存文件夹
  5. 替换来自 http://www.oldsite.comhttp://www.newsite.com
  6. 恢复新服务器上的数据库,
  7. 修改local.xml文件为适合新的数据库主机、登录名和密码。
  8. 将系统文件上传到新服务器

一切似乎都工作正常,除了产品图像由于某种原因没有显示在前端之外。

例如,这是我通过 firebug 获得的应该显示的图像的路径:

http://www.newsite.com/media/catalog/product/cache/1/small_image/113x113/9df78eab33525d08d6e5fb8d27136e95/1/_/1_9 .jpg

当我在 FTP 中搜索该站点应该显示的图像路径时,该文件实际上就在那里。我可以下载它并在我的计算机上显示它。我不知道为什么会发生这种情况。这对我来说没有任何意义。

这个 /media/catalog/product/cache/ 是系统生成的,因为我在上传网站之前自己删除了它,所以我猜这不是与缓存相关的问题。

好吧,我已经尽我所能描述了这个问题。我希望你能帮助我。

编辑:
嗯,原来问题出在 media 文件夹内的 .htaccess 文件!删除文件->问题解决了!

I recently migrated my magento website to a different server, and here's the process I used:

  1. made a dump of the database.
  2. copied all the system files from the FTP to my hard drive.
  3. emptied the VAR folder
  4. emptied the media cache folders
  5. replaced the strings in the SQL dump from http://www.oldsite.com to http://www.newsite.com
  6. restored the database on the new server
  7. modified the local.xml file to suit the new database host, login and password.
  8. uploaded the system files to the new server

Everything seems to work fine, except for the fact that the product images are not being displayed on the frontend for some reason.

For example, here's a path from an image that was supposed to be showing, which I got through firebug:

http://www.newsite.com/media/catalog/product/cache/1/small_image/113x113/9df78eab33525d08d6e5fb8d27136e95/1/_/1_9.jpg

When I search for the path of the image the site is supposed to show in the FTP, the file is actually there. I can download it and display it on my computer. I don't know why this is happening. It doesn't make any sense to me.

This /media/catalog/product/cache/ was generated by the system, because I erased it myself before uploading the site, so I guess it isn't a cache related issue.

Well, I described the issue the best I could. I hope you can help me out.

EDIT:
Hmm, it turns out the problem was the .htaccess file inside the media folder! Removed the file -> Problem solved!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

<逆流佳人身旁 2024-09-20 07:50:41

为了防止其他人遇到同样的问题,删除媒体文件夹中的 .htaccess 就可以解决问题。我不知道这是否是最好的解决方案!谢谢!

Just in case anyone else has the same problem, removing the .htaccess in the media folder did the trick. I don't know if that's the best possible solution though! Thanks!

や三分注定 2024-09-20 07:50:41

将上述 .htaccess 文件中的 Options All -Indexes 更改为 Options -Indexes

Change Options All -Indexes to Options -Indexes in the above mentioned .htaccess file.

偷得浮生 2024-09-20 07:50:41
  • 将所有系统文件从 FTP 复制到我的硬盘。
  • 这让我有点怀疑。 Magento 在媒体文件夹中有区分大小写的文件夹。例如,同一位置会有一个“a”文件夹和一个“A”文件夹。

    如果您通过 FTP 将未归档的文件(逐个文件)下载到 Windows 计算机,这会导致冲突并会忽略多达一半的图像。

    1. copied all the system files from the FTP to my hard drive.

    This one makes me a bit suspecting. Magento has case-sensitive folders in the media folder. There would be, for instance, an 'a' folder and an 'A' folder in the same location.

    If you downloaded your files unarchived (file by file) via FTP to a Windows machine, this would cause a conflict and would omit up to half your images.

    只是在用心讲痛 2024-09-20 07:50:41

    好的,由于所有内容都通过基本 URL 进行了检查,如果您在旧服务器上有 cPanel,我的下一个建议是迁移路径选项,而且由于大多数服务器都这样做,这应该会有所帮助:

    1. 使用 cPanel 创建帐户的完整备份。这将创建整个帐户的 tar.gz。
    2. 将压缩后的备份下载到您的计算机上并解压缩。
    3. 查找 home_dir.tar - 这是包含您的 HTML 根信息的内容。您可以直接将其上传到服务器并使用 SSH 解压,也可以在本地计算机上执行此操作并上传。
    4. 在解压的备份中找到 SQL 文件夹。那里应该有你的数据库转储。使用 source 将该信息放入新数据库中。
    5. 在服务器上,删除 use_cache.ser 并更改新数据库的配置信息。
    6. 您的 .htaccess 应该已经出现在 home_dir.tar 中,但请确保根据我们的其他问题它是正确的

    一旦完成,您应该可以完全正常工作,除非您需要在数据库中进行更改 base_url对于新服务器。

    Ok, since everything checked out with the base URL, my next suggestion is a migration path option if you have cPanel on the old server, and since most do, this should help:

    1. Create a full backup of the account using cPanel. This will create a tar.gz of the entire account.
    2. Download the tarred backup to your computer and unzip.
    3. Find home_dir.tar - this is what contains your HTML root information. You can either upload this directly to the server and untar there using SSH, or do it on your local computer and upload.
    4. Find the SQL folder in the untarred backup. There should be a dump of your database there. Use source to put that information into a new database.
    5. On the server, delete use_cache.ser and change config information for the new database.
    6. Your .htaccess should have come over in the home_dir.tar, but make sure that it's correct per our other question

    Once that's done, you should be fully functional, unless you need to make changes in the database base_url for the new server.

    汹涌人海 2024-09-20 07:50:41

    Magento 1.7 到 1.9 升级中不显示图像:

    我的解决方案

    在 /media/.htaccess 中

    修复选项语法:

    # Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes
    Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes
    

    删除了这些。可能与站点根目录中的.htaccess冲突?

    # For security reasons, Option followsymlinks cannot be overridden.
    #   Options +FollowSymLinks
    #   Options +SymLinksIfOwnerMatch
    #   RewriteEngie on
    

    还将 .htaccess 的所有权更改为 apache

    chown  apache:apache /var/www/mystore/media/.htaccess
    

    想了解为什么这些可能会导致 500 错误的意见。

    Images not showing in Magento 1.7 to 1.9 upgrade:

    My solution:

    in /media/.htaccess

    fixed options syntax:

    # Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes
    Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes
    

    removed these. Maybe conflict with .htaccess in site root directory??

    # For security reasons, Option followsymlinks cannot be overridden.
    #   Options +FollowSymLinks
    #   Options +SymLinksIfOwnerMatch
    #   RewriteEngie on
    

    also changed ownership of .htaccess to apache

    chown  apache:apache /var/www/mystore/media/.htaccess
    

    Would like opinion of why these may be causing 500 errors.

    梦忆晨望 2024-09-20 07:50:41
    php bin/magento catalog:images:resize
    

    这对我有帮助,但需要很长时间才能完成

    php bin/magento catalog:images:resize
    

    This helped me, but it take's a lot of time to complete

    浅语花开 2024-09-20 07:50:41

    对于 magento 2.4.5
    在 pub//media/.htaccess 中将

    “FollowSymLinks”更改为“SymLinksIfOwnerMatch”。示例:

    ##############################################

    启用重写

    Options +SymLinksIfOwnerMatch
    RewriteEngine on
    
    ## you can put here your pub/media folder path relative to web root
    #RewriteBase /magento/pub/media/
    

    ## ############################################

    for magento 2.4.5
    in pub//media/.htaccess

    change „FollowSymLinks“ to „SymLinksIfOwnerMatch“. example:

    ############################################

    enable rewrites

    Options +SymLinksIfOwnerMatch
    RewriteEngine on
    
    ## you can put here your pub/media folder path relative to web root
    #RewriteBase /magento/pub/media/
    

    ############################################

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文