Tracking Script: mtc.js 404

  1. 7 months ago

    Hello all!

    I've been having a hard time troubleshooting an issue. Mautic is not tracking data from my website. I'm running Mautic on a t2.nano routed to http://mautic.[mydomain].com.

    My main site is using the Joomla plugin, which is outputting this code:

            (function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
            w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
            m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
        })(window,document,'script','https://mautic.rightoncueservices.com/mtc.js','mt');

    In my Chrome Dev Tools, I receive the following error:

    Failed to load resource: the server responded with a status of 404 (Not Found) https://mautic.rightoncueservices.com/mtc.js

    I tried tail -F /var/log/httpd/* and found that the server is definitely receiving requests but that it is sending back a 404 error.

    I found an article https://www.mautic.org/community/index.php/4626-mtc-js-not-found/0 but it is for Njinx configurations. I'm using Apache.

    I think the same problem as above is happening: Apache is trying to simply get a file rather than execute PHP. Not sure if this is the right direction, but it seems like I need to add "js" as a registered php stream. I'm by no means an Apache expert, however. Any suggestions on how to fix this?

    System Specs:

    System	Linux 4.4.44-39.55.amzn1.x86_64 #1 SMP Mon Jan 30 18:15:53 UTC 2017 x86_64
    Build Date	Jan 18 2017 19:14:03
    Server API	Apache 2.0 Handler
    Virtual Directory Support	disabled
    Configuration File (php.ini) Path	/etc/php-7.0.conf:/etc
    Loaded Configuration File	/etc/php.ini
    Scan this dir for additional .ini files	/etc/php-7.0.d
    Additional .ini files parsed	/etc/php-7.0.d/20-bz2.ini, /etc/php-7.0.d/20-calendar.ini, /etc/php-7.0.d/20-ctype.ini, /etc/php-7.0.d/20-curl.ini, /etc/php-7.0.d/20-dom.ini, /etc/php-7.0.d/20-exif.ini, /etc/php-7.0.d/20-fileinfo.ini, /etc/php-7.0.d/20-ftp.ini, /etc/php-7.0.d/20-gettext.ini, /etc/php-7.0.d/20-iconv.ini, /etc/php-7.0.d/20-imap.ini, /etc/php-7.0.d/20-intl.ini, /etc/php-7.0.d/20-json.ini, /etc/php-7.0.d/20-mcrypt.ini, /etc/php-7.0.d/20-mysqlnd.ini, /etc/php-7.0.d/20-pdo.ini, /etc/php-7.0.d/20-phar.ini, /etc/php-7.0.d/20-posix.ini, /etc/php-7.0.d/20-shmop.ini, /etc/php-7.0.d/20-simplexml.ini, /etc/php-7.0.d/20-sockets.ini, /etc/php-7.0.d/20-sqlite3.ini, /etc/php-7.0.d/20-sysvmsg.ini, /etc/php-7.0.d/20-sysvsem.ini, /etc/php-7.0.d/20-sysvshm.ini, /etc/php-7.0.d/20-tokenizer.ini, /etc/php-7.0.d/20-xml.ini, /etc/php-7.0.d/20-xmlwriter.ini, /etc/php-7.0.d/20-xsl.ini, /etc/php-7.0.d/20-zip.ini, /etc/php-7.0.d/30-mysqli.ini, /etc/php-7.0.d/30-pdo_mysql.ini, /etc/php-7.0.d/30-pdo_sqlite.ini, /etc/php-7.0.d/30-wddx.ini, /etc/php-7.0.d/30-xmlreader.ini, /etc/php-7.0.d/php.ini
    PHP API	20151012
    PHP Extension	20151012
    Zend Extension	320151012
    Zend Extension Build	API320151012,NTS
    PHP Extension Build	API20151012,NTS
    Debug Build	no
    Thread Safety	disabled
    Zend Signal Handling	disabled
    Zend Memory Manager	enabled
    Zend Multibyte Support	disabled
    IPv6 Support	enabled
    DTrace Support	enabled
    Registered PHP Streams	https, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
    Registered Stream Socket Transports	tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
    Registered Stream Filters	zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*
  2. Edited 7 months ago by MxyzptlkFishStix

    Is AllowOverrides disabled? Are rewrites enabled in Apache? Is there a .htaccess file in the Mautic root directory?

    -image-

  3. Howdy ...FishStix!

    There is a .htaccess which is currently configured like this:

    # Use the front controller as index file. It serves as a fallback solution when
    # every other rewrite/redirect fails (e.g. in an aliased environment without
    # mod_rewrite). Additionally, this reduces the matching process for the
    # start page (path "/") because otherwise Apache will apply the rewriting rules
    # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
    #DirectoryIndex index.php
    
    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        # Set Authorization header for OAuth1a for when php is running under fcgi
        RewriteCond %{HTTP:Authorization} .+
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
        # Determine the RewriteBase automatically and set it as environment variable.
        # If you are using Apache aliases to do mass virtual hosting or installed the
        # project in a subdirectory, the base path will be prepended to allow proper
        # resolution of the app.php file and to redirect to the correct URI. It will
        # work in environments without path prefix as well, providing a safe, one-size
        # fits all solution. But as you do not need it in this case, you can comment
        # the following 2 lines to eliminate the overhead.
        RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
        RewriteRule ^(.*) - [E=BASE:%1]
    
        # Redirect to URI without front controller to prevent duplicate content
        # (with and without `/app.php`). Only do this redirect on the initial
        # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
        # endless redirect loop (request -> rewrite to front controller ->
        # redirect -> request -> ...).
        # So in case you get a "too many redirects" error or you always get redirected
        # to the start page because your Apache does not expose the REDIRECT_STATUS
        # environment variable, you have 2 choices:
        # - disable this feature by commenting the following 2 lines or
        # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
        #   following RewriteCond (best solution)
        RewriteCond %{ENV:REDIRECT_STATUS} ^$
        RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
    
        # If the requested filename exists, simply serve it.
        # We only want to let Apache serve files and not directories.
        RewriteCond %{REQUEST_FILENAME} -f
        RewriteRule .? - [L]
    
        # Rewrite all other queries to the front controller.
        RewriteRule .? %{ENV:BASE}/index.php [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        <IfModule mod_alias.c>
            # When mod_rewrite is not available, we instruct a temporary redirect of
            # the start page to the front controller explicitly so that the website
            # and the generated links can still be used.
            RedirectMatch 302 ^(?!/(index\.php|index_dev\.php|app|addons|plugins|media|upgrade))(/(.*))$ /index.php$2
            # RedirectTemp cannot be used instead
        </IfModule>
    </IfModule>
    
    <IfModule mod_php5.c>
        # @link https://github.com/mautic/mautic/issues/1504
        php_value always_populate_raw_post_data -1
    </IfModule>

    There is a mod_rewrite enabled within Apache. The current config for url_rewriter.tags:
    Local Value a=href,area=href,frame=src,input=src,form=fakeentry
    Master Value a=href,area=href,frame=src,input=src,form=fakeentry

    I appreciate your help. I'm learning, but I feel like not fast enough!

  4. What distro are you on?

  5. I'm on 2.6.0

  6. Edited 7 months ago by MxyzptlkFishStix

    No. What distribution of Linux are you running i.e. Debian, Ubuntu, CentOS, etc.

    The image above I posted shows that rewrites aren't enabled.

  7. Gotcha. I'm on Amazon AMI Linux 2016.09
    https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/

  8. Edited 7 months ago by MrMusicMan

    My httpd.conf AllowOverrides was set to None for <Directory "/var/www/html"> . It's now set to All. Specifically, it looks like this:

    <Directory "/var/www/html">
      Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Order allow,deny
       allow from all
    </Directory>

    Now I'm receiving error 500's and 301's (enabled both js and pixel for now):

    POST https://mautic.rightoncueservices.com/mtc/event 500 (Internal Server Error)
    mautic.rightoncueservices.com/mtracking.gif?page_title=Right%20On%20Cue%20S…track=unknown&adblock=false&fingerprint=5941caeb582809b85b5a03a4eefe14ca:1 GET https://mautic.rightoncueservices.com/mtracking.gif?page_title=Right%20On%2…t_track=unknown&adblock=false&fingerprint=5941caeb582809b85b5a03a4eefe14ca 500 (Internal Server Error)
    $ curl -IL https://mautic.rightoncueservices.com/index.php/mtc.js
    HTTP/1.1 301 Moved Permanently
    Date: Thu, 16 Feb 2017 16:22:32 GMT
    Server: Apache/2.4.25 (Amazon) OpenSSL/1.0.1k-fips PHP/7.0.14
    Location: https://mautic.rightoncueservices.com/mtc.js
    Content-Type: text/html; charset=iso-8859-1
    
    HTTP/1.1 200 OK
    Date: Thu, 16 Feb 2017 16:22:32 GMT
    Server: Apache/2.4.25 (Amazon) OpenSSL/1.0.1k-fips PHP/7.0.14
    X-Powered-By: PHP/7.0.14
    Set-Cookie: c87686a82fc35a3078911e55fbf7b129=bhlstilki1rc0d2up119kjlcb0; path=/; HttpOnly
    Cache-Control: no-cache
    Content-Type: application/javascript
  9. Clear your cache as the user apache is running under.

    sudo -u "user apache is running under" php app/console cache:clear
  10. Hi there,

    I successfully cleared the cache. Now I'm receiving an error 500 attempting to access any part of the Mautic site.
    https://mautic.rightoncueservices.com/

  11. Did you clear the cache as the web server user that has write permission to app/cache? If not, you going to have problems. Delete the app/cache/prod directory and refresh Mautic in your browser.

  12. That took care of it. I did use -u apache which is my apache user. It said it was a successful clear. hmm.

    Thank you again!

 

or Sign Up to reply!