magento文件路径错误

mm5n2pyu  于 2021-06-25  发布在  Mysql
关注(0)|答案(3)|浏览(493)

在magento上,除了index.php之外,我在获取任何东西方面都遇到了问题。最终得到了所有要执行的东西,我不仅仅遇到了一个文件的url不正确的简单问题。
例如:站点正在请求 .../static/version1111/.../logo.svg 这是行不通的。 .../static/.../logo.svg 另一方面是。
问题截图:

我不知道该怎么解决这个问题。
当前尝试的内容:
1)

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. RewriteBase /pub/static/ # <- Add This

这不起作用,但是完全删除/pub/static中的.htaccess文件也没有什么区别。blow是apache2.conf和.htaccess的参考文件。
形态:

  1. # This is the main Apache server configuration file. It contains the
  2. # configuration directives that give the server its instructions.
  3. # See http://httpd.apache.org/docs/2.4/ for detailed information about
  4. # the directives and /usr/share/doc/apache2/README.Debian about Debian specific
  5. # hints.
  6. #
  7. #
  8. # Summary of how the Apache 2 configuration works in Debian:
  9. # The Apache 2 web server configuration in Debian is quite different to
  10. # upstream's suggested way to configure the web server. This is because Debian's
  11. # default Apache2 installation attempts to make adding and removing modules,
  12. # virtual hosts, and extra configuration directives as flexible as possible, in
  13. # order to make automating the changes and administering the server as easy as
  14. # possible.
  15. # It is split into several files forming the configuration hierarchy outlined
  16. # below, all located in the /etc/apache2/ directory:
  17. #
  18. # /etc/apache2/
  19. # |-- apache2.conf
  20. # | `-- ports.conf
  21. # |-- mods-enabled
  22. # | |-- *.load
  23. # | `-- *.conf
  24. # |-- conf-enabled
  25. # | `-- *.conf
  26. # `-- sites-enabled
  27. # `-- *.conf
  28. #
  29. #
  30. # * apache2.conf is the main configuration file (this file). It puts the pieces
  31. # together by including all remaining configuration files when starting up the
  32. # web server.
  33. #
  34. # * ports.conf is always included from the main configuration file. It is
  35. # supposed to determine listening ports for incoming connections which can be
  36. # customized anytime.
  37. #
  38. # * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
  39. # directories contain particular configuration snippets which manage modules,
  40. # global configuration fragments, or virtual host configurations,
  41. # respectively.
  42. #
  43. # They are activated by symlinking available configuration files from their
  44. # respective *-available/ counterparts. These should be managed by using our
  45. # helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
  46. # their respective man pages for detailed information.
  47. #
  48. # * The binary is called apache2. Due to the use of environment variables, in
  49. # the default configuration, apache2 needs to be started/stopped with
  50. # /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
  51. # work with the default configuration.
  52. # Global configuration
  53. #
  54. #
  55. # ServerRoot: The top of the directory tree under which the server's
  56. # configuration, error, and log files are kept.
  57. #
  58. # NOTE! If you intend to place this on an NFS (or otherwise network)
  59. # mounted filesystem then please read the Mutex documentation (available
  60. # at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
  61. # you will save yourself a lot of trouble.
  62. #
  63. # Do NOT add a slash at the end of the directory path.
  64. #
  65. # ServerRoot "/etc/apache2"
  66. #
  67. # The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
  68. #
  69. # Mutex file:${APACHE_LOCK_DIR} default
  70. #
  71. # The directory where shm and other runtime files will be stored.
  72. #
  73. DefaultRuntimeDir ${APACHE_RUN_DIR}
  74. #
  75. # PidFile: The file in which the server should record its process
  76. # identification number when it starts.
  77. # This needs to be set in /etc/apache2/envvars
  78. #
  79. PidFile ${APACHE_PID_FILE}
  80. #
  81. # Timeout: The number of seconds before receives and sends time out.
  82. #
  83. Timeout 300
  84. #
  85. # KeepAlive: Whether or not to allow persistent connections (more than
  86. # one request per connection). Set to "Off" to deactivate.
  87. #
  88. KeepAlive On
  89. #
  90. # MaxKeepAliveRequests: The maximum number of requests to allow
  91. # during a persistent connection. Set to 0 to allow an unlimited amount.
  92. # We recommend you leave this number high, for maximum performance.
  93. #
  94. MaxKeepAliveRequests 100
  95. #
  96. # KeepAliveTimeout: Number of seconds to wait for the next request from the
  97. # same client on the same connection.
  98. #
  99. KeepAliveTimeout 5
  100. # These need to be set in /etc/apache2/envvars
  101. User ${APACHE_RUN_USER}
  102. Group ${APACHE_RUN_GROUP}
  103. #
  104. # HostnameLookups: Log the names of clients or just their IP addresses
  105. # e.g., www.apache.org (on) or 204.62.129.132 (off).
  106. # The default is off because it'd be overall better for the net if people
  107. # had to knowingly turn this feature on, since enabling it means that
  108. # each client request will result in AT LEAST one lookup request to the
  109. # nameserver.
  110. #
  111. HostnameLookups Off
  112. # ErrorLog: The location of the error log file.
  113. # If you do not specify an ErrorLog directive within a <VirtualHost>
  114. # container, error messages relating to that virtual host will be
  115. # logged here. If you *do* define an error logfile for a <VirtualHost>
  116. # container, that host's errors will be logged there and not here.
  117. #
  118. ErrorLog ${APACHE_LOG_DIR}/error.log
  119. #
  120. # LogLevel: Control the severity of messages logged to the error_log.
  121. # Available values: trace8, ..., trace1, debug, info, notice, warn,
  122. # error, crit, alert, emerg.
  123. # It is also possible to configure the log level for particular modules, e.g.
  124. # "LogLevel info ssl:warn"
  125. #
  126. LogLevel warn
  127. # Include module configuration:
  128. IncludeOptional mods-enabled/*.load
  129. IncludeOptional mods-enabled/*.conf
  130. # Include list of ports to listen on
  131. Include ports.conf
  132. # Sets the default security model of the Apache2 HTTPD server. It does
  133. # not allow access to the root filesystem outside of /usr/share and /var/www.
  134. # The former is used by web applications packaged in Debian,
  135. # the latter may be used for local directories served by the web server. If
  136. # your system is serving content from a sub-directory in /srv you must allow
  137. # access here, or in any related virtual host.
  138. <Directory />
  139. Options FollowSymLinks
  140. AllowOverride All
  141. Require all granted
  142. </Directory>
  143. <Directory /usr/share>
  144. AllowOverride All
  145. Require all granted
  146. </Directory>
  147. <Directory /var/www/>
  148. Options Indexes FollowSymLinks
  149. AllowOverride All
  150. Require all granted
  151. </Directory>
  152. # <Directory /srv/>
  153. # Options Indexes FollowSymLinks
  154. # AllowOverride All
  155. # Require all granted
  156. # </Directory>
  157. # AccessFileName: The name of the file to look for in each directory
  158. # for additional configuration directives. See also the AllowOverride
  159. # directive.
  160. #
  161. AccessFileName .htaccess
  162. #
  163. # The following lines prevent .htaccess and .htpasswd files from being
  164. # viewed by Web clients.
  165. #
  166. <FilesMatch "^\.ht">
  167. Require all denied
  168. </FilesMatch>
  169. #
  170. # The following directives define some format nicknames for use with
  171. # a CustomLog directive.
  172. #
  173. # These deviate from the Common Log Format definitions in that they use %O
  174. # (the actual bytes sent including headers) instead of %b (the size of the
  175. # requested file), because the latter makes it impossible to detect partial
  176. # requests.
  177. #
  178. # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
  179. # Use mod_remoteip instead.
  180. #
  181. LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
  182. LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
  183. LogFormat "%h %l %u %t \"%r\" %>s %O" common
  184. LogFormat "%{Referer}i -> %U" referer
  185. LogFormat "%{User-agent}i" agent
  186. # Include of directories ignores editors' and dpkg's backup files,
  187. # see README.Debian for details.
  188. # Include generic snippets of statements
  189. IncludeOptional conf-enabled/*.conf
  190. # Include the virtual host configurations:
  191. IncludeOptional sites-enabled/*.conf
  192. # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

.htaccess访问:

  1. <IfModule mod_php5.c>
  2. php_flag engine 0
  3. </IfModule>
  4. <IfModule mod_php7.c>
  5. php_flag engine 0
  6. </IfModule>
  7. # To avoid situation when web server automatically adds extension to path
  8. Options -MultiViews
  9. <IfModule mod_rewrite.c>
  10. RewriteEngine On
  11. ## you can put here your pub/static folder path relative to web root
  12. RewriteBase /pub/static
  13. # Remove signature of the static files that is used to overcome the browser cache
  14. RewriteRule ^version.+?/(.+)$ $1 [L]
  15. RewriteCond %{REQUEST_FILENAME} !-f
  16. RewriteCond %{REQUEST_FILENAME} !-l
  17. RewriteRule .* ../static.php?resource=$0 [L]
  18. </IfModule>
  19. ############################################
  20. ## setting MIME types
  21. # JavaScript
  22. AddType application/javascript js jsonp
  23. AddType application/json json
  24. # HTML
  25. AddType text/html html
  26. # CSS
  27. AddType text/css css
  28. # Images and icons
  29. AddType image/x-icon ico
  30. AddType image/gif gif
  31. AddType image/png png
  32. AddType image/jpeg jpg
  33. AddType image/jpeg jpeg
  34. # SVG
  35. AddType image/svg+xml svg
  36. # Fonts
  37. AddType application/vnd.ms-fontobject eot
  38. AddType application/x-font-ttf ttf
  39. AddType application/x-font-otf otf
  40. AddType application/x-font-woff woff
  41. AddType application/font-woff2 woff2
  42. # Flash
  43. AddType application/x-shockwave-flash swf
  44. # Archives and exports
  45. AddType application/zip gzip
  46. AddType application/x-gzip gz gzip
  47. AddType application/x-bzip2 bz2
  48. AddType text/csv csv
  49. AddType application/xml xml
  50. <IfModule mod_headers.c>
  51. <FilesMatch .*\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$>
  52. Header append Cache-Control public
  53. </FilesMatch>
  54. <FilesMatch .*\.(zip|gz|gzip|bz2|csv|xml)$>
  55. Header append Cache-Control no-store
  56. </FilesMatch>
  57. </IfModule>
  58. <IfModule mod_expires.c>
  59. ############################################
  60. ## Add default Expires header
  61. ## http://developer.yahoo.com/performance/rules.html#expires
  62. ExpiresActive On
  63. # Data
  64. <FilesMatch \.(zip|gz|gzip|bz2|csv|xml)$>
  65. ExpiresDefault "access plus 0 seconds"
  66. </FilesMatch>
  67. ExpiresByType text/xml "access plus 0 seconds"
  68. ExpiresByType text/csv "access plus 0 seconds"
  69. ExpiresByType application/json "access plus 0 seconds"
  70. ExpiresByType application/zip "access plus 0 seconds"
  71. ExpiresByType application/x-gzip "access plus 0 seconds"
  72. ExpiresByType application/x-bzip2 "access plus 0 seconds"
  73. # CSS, JavaScript, html
  74. <FilesMatch \.(css|js|html)$>
  75. ExpiresDefault "access plus 1 year"
  76. </FilesMatch>
  77. ExpiresByType text/css "access plus 1 year"
  78. ExpiresByType text/html "access plus 1 year"
  79. ExpiresByType application/javascript "access plus 1 year"
  80. # Favicon, images, flash
  81. <FilesMatch \.(ico|gif|png|jpg|jpeg|swf|svg)$>
  82. ExpiresDefault "access plus 1 year"
  83. </FilesMatch>
  84. ExpiresByType image/gif "access plus 1 year"
  85. ExpiresByType image/png "access plus 1 year"
  86. ExpiresByType image/jpg "access plus 1 year"
  87. ExpiresByType image/jpeg "access plus 1 year"
  88. ExpiresByType image/svg+xml "access plus 1 year"
  89. # Fonts
  90. <FilesMatch \.(eot|ttf|otf|svg|woff|woff2)$>
  91. ExpiresDefault "access plus 1 year"
  92. </FilesMatch>
  93. ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
  94. ExpiresByType application/x-font-ttf "access plus 1 year"
  95. ExpiresByType application/x-font-otf "access plus 1 year"
  96. ExpiresByType application/x-font-woff "access plus 1 year"
  97. ExpiresByType application/font-woff2 "access plus 1 year"
  98. </IfModule>
  1. INSERT INTO core_config_data VALUES (NULL, 'default', 0, 'dev/static/sign', 0);

结果:

  1. mysql> SELECT * FROM core_config_data
  2. -> ;
  3. +-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  4. | config_id | scope | scope_id | path | value |
  5. +-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  6. | 1 | default | 0 | web/seo/use_rewrites | 1 |
  7. | 2 | default | 0 | web/unsecure/base_url | http://www.mymagento2.com/ |
  8. | 3 | default | 0 | web/secure/base_url | https://www.mymagento2.com/ |
  9. | 4 | default | 0 | general/locale/code | en_GB |
  10. | 5 | default | 0 | web/secure/use_in_frontend | NULL |
  11. | 6 | default | 0 | web/secure/use_in_adminhtml | NULL |
  12. | 7 | default | 0 | general/locale/timezone | UTC |
  13. | 8 | default | 0 | currency/options/base | GBP |
  14. | 9 | default | 0 | currency/options/default | GBP |
  15. | 10 | default | 0 | currency/options/allow | GBP |
  16. | 11 | default | 0 | general/region/display_all | 1 |
  17. | 12 | default | 0 | general/region/state_required | AT,BR,CA,CH,EE,ES,FI,HR,IN,LT,LV,RO,US |
  18. | 13 | default | 0 | catalog/category/root_id | 2 |
  19. | 14 | default | 0 | analytics/subscription/enabled | 1 |
  20. | 15 | default | 0 | crontab/default/jobs/analytics_subscribe/schedule/cron_expr | 0 * * * * |
  21. | 16 | default | 0 | sales/msrp/enabled | 1 |
  22. | 17 | default | 0 | carriers/tablerate/active | 1 |
  23. | 18 | default | 0 | carriers/tablerate/condition_name | package_value |
  24. | 19 | default | 0 | design/theme/theme_id | 2 |
  25. | 20 | default | 0 | design/head/includes | <link rel="stylesheet" type="text/css" media="all" href="{{MEDIA_URL}}styles.css" /> |
  26. | 21 | website | 0 | connector_configuration/transactional_data/order_statuses | canceled,closed,complete,fraud,holded,payment_review,paypal_canceled_reversal,paypal_reversed,pending,pending_payment,pending_paypal,processing |
  27. | 22 | website | 0 | connector_configuration/catalog_sync/catalog_type | simple,virtual,bundle,downloadable,configurable,grouped |
  28. | 23 | website | 0 | connector_configuration/catalog_sync/catalog_visibility | 1,2,3,4 |
  29. | 24 | default | 0 | connector_dynamic_content/external_dynamic_content_urls/passcode | AfT5cYVO0dLTorxzzbUFPOPtTLryLILo |
  30. | 27 | default | 0 | dev/static/sign | 0 |
  31. +-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  32. 25 rows in set (0.00 sec)

他没有工作。
提前谢谢
p、 我在用ubuntu

owfi6suc

owfi6suc1#

试试这个:
您需要更新/pub/static文件夹下的.htaccess文件。打开magento_dir/pub/static/.htaccess并添加以下代码:

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. RewriteBase /pub/static/ # <- Add This

或者,您可以通过使用以下查询将此记录添加到core\u config\u数据表中来禁用静态文件签名:
插入 core_config_data 值(null,'default',0,'dev/static/sign',0);在这种情况下,请记住,执行查询后必须刷新缓存。
我也有同样的问题,第二种选择对我有效。注:此答案的原件全部归功于克里斯蒂亚诺·卡斯基奥蒂

zvokhttg

zvokhttg2#

发现问题,我没有正确启用mod rewrite。我修正了:

  1. sudo a2enmod rewrite
  2. sudo service apache2 restart

来源:mateusz papiernik

06odsfpq

06odsfpq3#

在我的sql中运行此查询

  1. INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE value = 0;

然后清除配置缓存

  1. bin/magento cache:clean config

相关问题