I’ve been having problems getting anything but index.php to work on Magento. Having finally got everything to execute I’ve not just got a simple problem where the urls to files are incorrect.
For example: the site is requesting
.../static/version1111/.../logo.svg
which doesn’t work.
.../static/.../logo.svg
on the other hand does.
Screenshot of the issue:
I’m not sure how to go about fixing this.
Current things attempted:
1)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /pub/static/ # <- Add This
This didn’t work however completely deleting the .htaccess files in /pub/static made no difference either. Blow is the apache2.conf and .htaccess for reference.
conf:
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.
# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
# /etc/apache2/
# |-- apache2.conf
# | `-- ports.conf
# |-- mods-enabled
# | |-- *.load
# | `-- *.conf
# |-- conf-enabled
# | `-- *.conf
# `-- sites-enabled
# `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
# together by including all remaining configuration files when starting up the
# web server.
#
# * ports.conf is always included from the main configuration file. It is
# supposed to determine listening ports for incoming connections which can be
# customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
# directories contain particular configuration snippets which manage modules,
# global configuration fragments, or virtual host configurations,
# respectively.
#
# They are activated by symlinking available configuration files from their
# respective *-available/ counterparts. These should be managed by using our
# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
# their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
# the default configuration, apache2 needs to be started/stopped with
# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
# work with the default configuration.
# Global configuration
#
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"
#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default
#
# The directory where shm and other runtime files will be stored.
#
DefaultRuntimeDir ${APACHE_RUN_DIR}
#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log
#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride All
# Require all granted
#</Directory>
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^.ht">
Require all denied
</FilesMatch>
#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" vhost_combined
LogFormat "%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
.htaccess:
<IfModule mod_php5.c>
php_flag engine 0
</IfModule>
<IfModule mod_php7.c>
php_flag engine 0
</IfModule>
# To avoid situation when web server automatically adds extension to path
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
## you can put here your pub/static folder path relative to web root
RewriteBase /pub/static
# Remove signature of the static files that is used to overcome the browser cache
RewriteRule ^version.+?/(.+)$ $1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* ../static.php?resource=$0 [L]
</IfModule>
############################################
## setting MIME types
# JavaScript
AddType application/javascript js jsonp
AddType application/json json
# HTML
AddType text/html html
# CSS
AddType text/css css
# Images and icons
AddType image/x-icon ico
AddType image/gif gif
AddType image/png png
AddType image/jpeg jpg
AddType image/jpeg jpeg
# SVG
AddType image/svg+xml svg
# Fonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf
AddType application/x-font-otf otf
AddType application/x-font-woff woff
AddType application/font-woff2 woff2
# Flash
AddType application/x-shockwave-flash swf
# Archives and exports
AddType application/zip gzip
AddType application/x-gzip gz gzip
AddType application/x-bzip2 bz2
AddType text/csv csv
AddType application/xml xml
<IfModule mod_headers.c>
<FilesMatch .*.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$>
Header append Cache-Control public
</FilesMatch>
<FilesMatch .*.(zip|gz|gzip|bz2|csv|xml)$>
Header append Cache-Control no-store
</FilesMatch>
</IfModule>
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresActive On
# Data
<FilesMatch .(zip|gz|gzip|bz2|csv|xml)$>
ExpiresDefault "access plus 0 seconds"
</FilesMatch>
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType text/csv "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/zip "access plus 0 seconds"
ExpiresByType application/x-gzip "access plus 0 seconds"
ExpiresByType application/x-bzip2 "access plus 0 seconds"
# CSS, JavaScript, html
<FilesMatch .(css|js|html)$>
ExpiresDefault "access plus 1 year"
</FilesMatch>
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/html "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
# Favicon, images, flash
<FilesMatch .(ico|gif|png|jpg|jpeg|swf|svg)$>
ExpiresDefault "access plus 1 year"
</FilesMatch>
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
# Fonts
<FilesMatch .(eot|ttf|otf|svg|woff|woff2)$>
ExpiresDefault "access plus 1 year"
</FilesMatch>
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-otf "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
</IfModule>
2)
INSERT INTO core_config_data VALUES (NULL, 'default', 0, 'dev/static/sign', 0);
Result:
mysql> SELECT * FROM core_config_data
-> ;
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
| config_id | scope | scope_id | path | value |
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | default | 0 | web/seo/use_rewrites | 1 |
| 2 | default | 0 | web/unsecure/base_url | http://www.mymagento2.com/ |
| 3 | default | 0 | web/secure/base_url | https://www.mymagento2.com/ |
| 4 | default | 0 | general/locale/code | en_GB |
| 5 | default | 0 | web/secure/use_in_frontend | NULL |
| 6 | default | 0 | web/secure/use_in_adminhtml | NULL |
| 7 | default | 0 | general/locale/timezone | UTC |
| 8 | default | 0 | currency/options/base | GBP |
| 9 | default | 0 | currency/options/default | GBP |
| 10 | default | 0 | currency/options/allow | GBP |
| 11 | default | 0 | general/region/display_all | 1 |
| 12 | default | 0 | general/region/state_required | AT,BR,CA,CH,EE,ES,FI,HR,IN,LT,LV,RO,US |
| 13 | default | 0 | catalog/category/root_id | 2 |
| 14 | default | 0 | analytics/subscription/enabled | 1 |
| 15 | default | 0 | crontab/default/jobs/analytics_subscribe/schedule/cron_expr | 0 * * * * |
| 16 | default | 0 | sales/msrp/enabled | 1 |
| 17 | default | 0 | carriers/tablerate/active | 1 |
| 18 | default | 0 | carriers/tablerate/condition_name | package_value |
| 19 | default | 0 | design/theme/theme_id | 2 |
| 20 | default | 0 | design/head/includes | <link rel="stylesheet" type="text/css" media="all" href="{{MEDIA_URL}}styles.css" /> |
| 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 |
| 22 | website | 0 | connector_configuration/catalog_sync/catalog_type | simple,virtual,bundle,downloadable,configurable,grouped |
| 23 | website | 0 | connector_configuration/catalog_sync/catalog_visibility | 1,2,3,4 |
| 24 | default | 0 | connector_dynamic_content/external_dynamic_content_urls/passcode | AfT5cYVO0dLTorxzzbUFPOPtTLryLILo |
| 27 | default | 0 | dev/static/sign | 0 |
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
25 rows in set (0.00 sec)
Hasnt worked.
Thanks in advance
P.s
I’m using Ubuntu
3
Answers
Found the problem, I hadn't properly enabled mod-rewrite. I fixed with:
Source: Mateusz Papiernik
Try this:
You need to update the .htaccess file under /pub/static folder. Open MAGENTO_DIR/pub/static/.htaccess and add the following code:
Alternatively, you can disable static file signing by adding this record into the core_config_data table with this query:
INSERT INTO
core_config_data
VALUES (NULL, ‘default’, 0, ‘dev/static/sign’, 0);In this case, keep in mind that you have to flush the cache after executing the query.
I had the same issue and the second option worked for me.
Note: The original of this answer from here
All credit to Cristiano Casciotti
run this query in my sql
after that clear the config cache