【问题标题】:Magento home page works, but every other page gives 404 error, and can't access backend after migrationMagento 主页可以正常工作,但每隔一个页面都会出现 404 错误,迁移后无法访问后端
【发布时间】:2013-04-30 23:50:10
【问题描述】:

我将 Magento 站点从一台服务器移动到另一台服务器(域名未更改),在新服务器上主页显示正常,但是当我单击链接时,每个链接都会出现 404 错误.我也尝试访问管理面板,但我收到了同样的问题。我尝试从 URL 中删除“index.php”,看看这是否有所不同,但错误仍然存​​在。

我已删除缓存文件夹和会话文件夹中的文件。我已经更新了 local.xml 文件以使用新的数据库详细信息,这似乎很好,因为 Magento 正在显示来自数据库的数据。

我的 .htaccess 文件是标准文件,但在这里供您参考。

############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi

#    Action php5-cgi /cgi-bin/php5-cgi
#    AddHandler php5-cgi .php

############################################
## GoDaddy specific options

#   Options -MultiViews

## you might also need to add this line to php.ini
##     cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini

############################################
## this line is specific for 1and1 hosting

    #AddType x-mapp-php5 .php
    #AddHandler x-mapp-php5 .php

############################################
## default index file

    DirectoryIndex index.php

<IfModule mod_php5.c>

############################################
## adjust memory limit

#    php_value memory_limit 64M
    php_value memory_limit 256M
    php_value max_execution_time 18000

############################################
## disable magic quotes for php request vars

    php_flag magic_quotes_gpc off

############################################
## disable automatic session start
## before autoload was initialized

    php_flag session.auto_start off

############################################
## enable resulting html compression

    #php_flag zlib.output_compression on

###########################################
# disable user agent verification to not break multiple image upload

    php_flag suhosin.session.cryptua off

###########################################
# turn off compatibility with PHP4 when dealing with objects

    php_flag zend.ze1_compatibility_mode Off

</IfModule>

<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload

    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

<IfModule mod_deflate.c>

############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

    # Insert filter on all content
    ###SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

    # Netscape 4.x has some problems...
    #BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    #BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Don't compress images
    #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
    #Header append Vary User-Agent env=!dont-vary

</IfModule>

<IfModule mod_ssl.c>

############################################
## make HTTPS env vars available for CGI mode

    SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

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

    Options +FollowSymLinks
    RewriteEngine on

############################################
## you can put here your magento root folder
## path relative to web root

    #RewriteBase /magento/

############################################
## uncomment next line to enable light API calls processing

#    RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]

############################################
## 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]

############################################
## redirect for mobile user agents

    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]

############################################
## 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>


############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

    AddDefaultCharset Off
    #AddDefaultCharset UTF-8

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresDefault "access plus 1 year"

</IfModule>

############################################
## By default allow all access

    Order allow,deny
    Allow from all

###########################################
## Deny access to release notes to prevent disclosure of the installed Magento version

    <Files RELEASE_NOTES.txt>
        order allow,deny
        deny from all
    </Files>

############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags

    #FileETag none

有人有什么想法吗?

【问题讨论】:

  • 哪个 404 页面。默认的apache页面? Magento 的众多 404 页之一?如果没有这些信息,很难调试它。 alanstorm.com/magentos_many_404_pages
  • 它给出了一个服务器 404 错误页面。

标签: magento migration http-status-code-404


【解决方案1】:

我遇到了同样的问题并通过更改 .htaccess 文件行解决了它:

RewriteBase /store/magento/

把你的路径相对于magento root

【讨论】:

    【解决方案2】:
    1. 执行a2enmod rewrite(启用重写模块)
    2. 执行service apache2 restart/etc/init.d/apache2 restartsytemctl restart apache2
    3. 将此添加到您的 .htaccess 文件中:

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

    【讨论】:

      【解决方案3】:

      这通常发生在 mod_rewrite 未启用时。可能是它没有安装,但更有可能是您的虚拟主机配置文件没有正确设置。检查this link 以获取参考。

      在实时服务器上添加 &lt;IfModule mod_rewrite.c&gt; 部分。默认法师.htaccess文件在这里https://github.com/emizentech/magento2/blob/master/.htaccess.sample

      【讨论】:

      • 这就是问题所在。服务器正在运行 ngnix,但我似乎无法让 mod_rewrite 等效于它。所以我把它移到另一台运行 Apache(和 mod_rewrite)的服务器上,它工作正常。
      【解决方案4】:

      我不得不放松对名为 html 的根 Magento 文件夹的权限。 (将 AWS EC2 与 Amazon Linux AMI 结合使用)

      此更改还阻止了 Magento 管理员中显示的消息:“您的 Web 服务器配置不正确。因此,可以从外部访问包含敏感信息的配置文件。请联系您的托管服务提供商。 em>"

      • 编辑/etc/httpd/conf/httpd.conf
      • 找到以&lt;Directory "/var/www/html"&gt;开头的节点
      • 更改它,使指令如下所示(我保留了默认的 cmets,但没有在下面包含它们):
      <Directory "/var/www/html">
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Allow from All
        Require all granted
      </Directory>
      
      • 重启 Apache sudo service httpd reload

      【讨论】:

      • 这个解决方案在 magento 2.4.1 中对我有用。在 /etc/apache2/apache2.conf 中添加上述代码行并重新启动 apache2。
      猜你喜欢
      • 1970-01-01
      • 2017-07-17
      • 2022-07-20
      • 2015-06-26
      • 1970-01-01
      • 2019-09-20
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      相关资源
      最近更新 更多