Answer the question
In order to leave comments, you need to log in
nginx. Processing css files with php interpreter
Please help with writing a regular expression in location for nginx.
There was a need to process css files from a certain directory by the php interpreter. (example: styles.css?423421423e3).
In .htaccess I wrote:
<Files styles.css>
ForceType application/x-httpd-php
AddHandler application/x-httpd-php .css
</Files>
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root /var/www/myuser/data/www/site.ru;
access_log /var/www/httpd-logs/site.ru.access.log ;
access_log /var/www/nginx-logs/myuser isp;
}
Answer the question
In order to leave comments, you need to log in
Firstly, it is not clear now, the regular expression for file types is included in some kind of location or is registered at the top level under server.
I would write like this
location '/assets/' {
location '/assets/do-not-serve-css' {
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root /var/www/myuser/data/www/site.ru;
access_log /var/www/httpd-logs/site.ru.access.log ;
access_log /var/www/nginx-logs/myuser isp;
}
}
location '/assets/feel-free-to-serve-css' {
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root /var/www/myuser/data/www/site.ru;
access_log /var/www/httpd-logs/site.ru.access.log ;
access_log /var/www/nginx-logs/myuser isp;
}
}
}
Return the location css as it was, and write a new location for your directory.
location ~* ^\/path\/to\/folder\/(.+)\.css$ {
# Ваш конфиг обработчика php
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question