Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: nginx regex help needed
PostPosted: Tue Apr 06, 2010 7:34 am 
Offline
Junior Member
User avatar

Joined: Sat Mar 13, 2010 2:50 pm
Posts: 33
Location: The Intarwebs
Twitter: stiobhart
following various tutorials on the intarwebs, i've managed to get a drupal site [which was previously on apache] up and running on nginx... with one major hiccup:

my site's theme has embedded PHP within some of its CSS files, to define colours/dimensions etc [for ease of making global changes]. under apache, i had set PHP to handle these CSS files by putting the following in an .htaccess file in the theme directory:

Code:
AddHandler application/x-httpd-php .css
php_value default_mimetype "text/css"


now, obviously the PHP inside these CSS files is no longer being parsed with the new nginx setup, so that the site layout is all over the show. what i need to do is tell nginx to hand over any CSS files it finds within /sites/<sitename>/themes/<themename> to php-fastcgi for processing, but unfortunately 99% of regex is 'alphabetti spaghetti' to me, so i'm not sure how i'd construct such a directive in the correct syntax.

can some regex guru give me a few pointers?

_________________
**************************
Mental Diarrhoea
**************************


Top
   
 Post subject:
PostPosted: Tue Apr 06, 2010 9:29 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
You shouldn't need any fancy regex try this

location ~* /sites/<sitename>/themes/<themename>/(.*)\.css$
{
//stuff to pass to php-fastcgi
}

It basically means all files in the sites/<sitename>/themes/<themename>/ directory that end in .css will be passed to php-fastcgi

If you want all .css files to be passed to php which is what AddHandler will have done in apache use

location ~* \.css
{
//stuff to pass to php
}


Top
   
 Post subject:
PostPosted: Tue Apr 06, 2010 9:52 am 
Offline
Junior Member
User avatar

Joined: Sat Mar 13, 2010 2:50 pm
Posts: 33
Location: The Intarwebs
Twitter: stiobhart
cheers for that.

unfortunately it didnae work. drupal is still ignoring the CSS file with the PHP embedded in it.

for now, i've just gone through and removed all the PHP conditionals from the CSS file and hardwired everything in instead - and it's working fine now

[i also had to remove the nginx directive which passed CSS files through to php-fastcgi, as the 'cleaned up' CSS didnae work with this directive still in place. this makes me wonder whether there's some difference between 'normal' PHP and php-fastcgi, whereby the latter disnae know how to handle a non-html file with PHP embedded?]

_________________
**************************
Mental Diarrhoea
**************************


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group