Magento:媒体文件返回未指定输入文件

时间:2014-04-08 19:15:59

标签: php .htaccess magento

我正在研究magento电子商务解决方案,而且我目前遇到了一个问题,我无法从php访问/ media目录中的文件。我已经google了很多,但还没有找到解决方案。

/ media目录中的.htaccess文件如下所示:

    Options All -Indexes
<IfModule mod_php5.c>
php_flag engine 0
</IfModule>

# AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
# Options -ExecCGI

<IfModule mod_rewrite.c>

############################################
## enable rewrites
    RewriteEngine on

############################################
## never rewrite for existing files
    RewriteCond %{REQUEST_FILENAME} !-f

############################################
## rewrite everything else to index.php
    RewriteRule .* ../get.php [L]
</IfModule>

1 个答案:

答案 0 :(得分:0)

我不是Apache重写的专家。但是,我认为您的重写条件不完整。以下是我用于大多数Magento网站的内容:

<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

############################################
## rewrite API2 calls to api.php (by now it is REST only)

    RewriteRule ^api/rest api.php?type=rest [QSA,L]

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

</IfModule>

另一种可能性是文件权限不适合媒体目录。您可以使用以下命令为整个应用程序修复它们,从根Magento目录中的命令行运行:

find . -type f -exec chmod 644 {} ;
find . -type d -exec chmod 755 {} ;
chmod o+w var var/.htaccess app/etc
chmod 550 pear
chmod -R o+w media