CSS problem after nginx rewrite for clean URLs

I am writing rewrite rules in nginx for clean URLs.

Following is the rule:

location / {
if (!-e $request_filename) {
rewrite ^/post/(.)/(.)/(.*)$ /post.php?a=$1&b=$2&c=$3 last;
}
}

Everytime I hit mydomain.com/post/123/456/abc-def it renders
mydomain.com/post.php?a=123&b=456&c=abc-def

Now the regex is right and php is rendered properly. But it is screwing
up my css.
The nav bar is garbled and images are not seen.
What could be the problem?

Are you using a static CSS file, or is the CSS being generated with
PHP? What do you see when you attempt to access the CSS file
directly?

Either way, it’s better to use more specific locations:

location /post {
rewrite …;
}

location /css {

css-specific settings, like “expires 10y”

}

location /images {

image-specific settings

}