# How does mautic-form.js work in nginx? Please share your nginx configuration wordpress + subfolder with mautic

**URL:** <https://forum.mautic.org/t/how-does-mautic-form-js-work-in-nginx-please-share-your-nginx-configuration-wordpress-subfolder-with-mautic/14137>\
**Category:** Product Support\
**Created:** [May 1, 2020, 3:45pm UTC](https://forum.mautic.org/t/how-does-mautic-form-js-work-in-nginx-please-share-your-nginx-configuration-wordpress-subfolder-with-mautic/14137 "2020-05-01T15:45:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![honggian](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/honggian/32/947_2.png) [@honggian](https://forum.mautic.org/u/honggian)\
**Post date:** [May 1, 2020, 3:45pm UTC](https://forum.mautic.org/t/how-does-mautic-form-js-work-in-nginx-please-share-your-nginx-configuration-wordpress-subfolder-with-mautic/14137/1 "2020-05-01T15:45:50Z")

</div>

**Your software**  
My Mautic version is: 2.16.2  
My PHP version is: 7.2.30

**Your problem**  
My problem is: I am using Mautic for test purpose based on my environment Nginx, MariaDB and Letsencrypt and HSTS options from WordOps( like EasyEngine V3, simple Nginx configuration command) in the subfolder environment. For the first time, I have mtc.js 404 error, but I solve when I install Mautic in the subfolder. My Nginx knowledge is limited, so I am keep searching whenever I meet the error.

When I insert the form using Mautic wordpress plugin to my existing Wordpress site in the same VPS, I found the following error. I can collect e-mail successfully, but when a test user(me) input e-mail, website doesn’t show any message.

I guess it is not Mautic problem, but I don’t know how Mautic work, so I need some comments or opinion. What should I consider to solve this problem?

These errors are showing in the log:

[Error] Failed to load resource: the server responded with a status of 404 () (mautic-form.js, line 0)  
[Error] Refused to execute [XXX Sex - Free Porn Videos at XXX.com](https://xxx.com/mautic/index.php/media/js/mautic-form.js) as script because “X-Content-Type: nosniff” was given and its Content-Type is not a script MIME type.

I am confusing Mautic, Nginx configuraiton, WordOps basic configuration which one make problem or combination of these programs. I am keep changing the configuration, but anything couldn’t help. When I couldn’t use mautic properly in this time, I have to consider other solution. Sorry.

Steps I have tried to fix the problem:

Here is my some setting for using Mautic for subfolder.

> server {
> 
> ```
> server_name xxx.com www.xxx.com;
> 
> access_log /var/log/nginx/xxx.com.access.log rt_cache;
> error_log /var/log/nginx/xxx.com.error.log;
> 
> root /var/www/xxx.com/htdocs;
> 
> index index.php index.html index.htm;
> 
> include common/php72.conf;
> 
> include common/wpcommon-php72.conf;
> include common/locations-wo.conf;
> include /var/www/xxx.com/conf/nginx/*.conf;
> 
> ```
> 
> ##Mautic configuration Start
> 
> ```
> location ^~ /mautic {
> alias /var/www/xxx.com/mautic;
> try_files $uri $uri/ @mautic;
> 
> location ~ \.php {
> fastcgi_pass php72;
> fastcgi_split_path_info ^(.+\.php)(.*)$;
> include /etc/nginx/fastcgi_params;
> }
> 
> ```
> 
> }
> 
> location @mautic {  
> rewrite /mautic/(.\*)$ /mautic/index.php?/$1 last;  
> }
> 
> ##Mautic Configuraiton End
> 
> }

Here is my /etc/nginx/common/php72.conf

> ## Original WordOps configuration Start
> 
> location / {  
> try\_files $uri $uri/ /index.php$is\_args$args;  
> }  
> location ~ .php$ {  
> try\_files $uri =404;  
> include fastcgi\_params;  
> fastcgi\_pass php72;  
> }
> 
> ## Original WordOps configuration End
> 
> ## I add this configuration for mautic-form.js but didn’t work
> 
> location ~ /mautic/index.php/media/js/mautic-form.js {  
> more\_set\_headers ‘Access-Control-Allow-Origin : \*’;  
> default\_type “application/javascript”;  
> try\_files $uri /index.php?$args @phpstream;  
> }
> 
> location @phpstream {  
> include fastcgi\_params;  
> fastcgi\_pass php72;  
> }

---

<div class="post-metadata">

**Author:** ![divs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/divs/32/3214_2.png) [@divs](https://forum.mautic.org/u/divs)\
**Post date:** [March 31, 2021, 4:30pm UTC](https://forum.mautic.org/t/how-does-mautic-form-js-work-in-nginx-please-share-your-nginx-configuration-wordpress-subfolder-with-mautic/14137/3 "2021-03-31T16:30:40Z")

</div>

Does this article still exist?

Thanks!

---

<div class="post-metadata">

**Author:** ![lexgabrees](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lexgabrees/32/4467_2.png) [@lexgabrees](https://forum.mautic.org/u/lexgabrees)\
**Post date:** [April 1, 2021, 7:47am UTC](https://forum.mautic.org/t/how-does-mautic-form-js-work-in-nginx-please-share-your-nginx-configuration-wordpress-subfolder-with-mautic/14137/4 "2021-04-01T07:47:13Z")

</div>

Hey divs …

The article is unavailable at the moment … I’m unsure if it will be coming back, to be honest …

---

<div class="post-metadata">

**Author:** ![divs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/divs/32/3214_2.png) [@divs](https://forum.mautic.org/u/divs)\
**Post date:** [April 1, 2021, 3:41pm UTC](https://forum.mautic.org/t/how-does-mautic-form-js-work-in-nginx-please-share-your-nginx-configuration-wordpress-subfolder-with-mautic/14137/5 "2021-04-01T15:41:47Z")

</div>

Hello Friend,

Thanks for the answer.
