I'm not sure if it's a wordpress or nginx problem
I'm making a plugin, but the plugin directory is a symlink. I think it's ok since the plugin is detected, can be activated, and even some parts are working (like a menu), but on a page where it launches a script at a chortcode, it must get a style.css file and it cannot with an error 404 not found
in the console :
so my symlink is here :
/path/to/wp-content/plugins/symlink_plugin_directory/
and my directory is elsewhere, with its files :
/another/path/to/plugin_directory/
index.php
style.css
the probleme has something to do with the symlink, because if I create a real directory in /path/to/wp-content/plugins/real_directory/style.css
with a copy of the style.css, it works
I call the style.css
file with : wp_enqueue_style('my_style', plugins_url('style.css', __FILE__));
so if instead I use : wp_enqueue_style('my_style', plugins_url('real_directory/style.css', dirname(__FILE__)))
, it works
And the path that is not working and should works (in my understanding), is :
https://my_site/wp-content/plugins/symlink_directory/style.css
compared to the one that works :
https://my_site/wp-content/plugins/real_directory/style.css
then what is wrong ?
what i tried ?
I was thinking maybe a GET method doesn't works with symlink in nginx, but I enabled it with disable_symlinks off;
like it says here : https://unix.stackexchange.com/questions/157022/make-nginx-follow-symlinks, but it doesn't resolve the problem (I tried to add it in both http{}
context and location ~ \.php${}
context)
also I checked that symlink files and directory had the read and execution permissions, according to this SO conversation : https://stackoverflow.com/questions/12624358/nginx-not-following-symlinks, and I hope I gave them the good user ownership (my nginx and wordpress programs runs in separate docker, I think a get it right because symlink and reallink have the same permissions and users)
and on the same conversation, there was the idea to add autoindex on;
, which I did, without luck
finally, I also tried to change the variable $document_root
to $realpath_root
in nginx php-fpm configuration, as explained here : https://joshtronic.com/2019/07/29/symlinks-with-nginx-and-php-fpm/, but no much success