0

lets say, I have an location /user/username/custom/custom.css I would like to server this location /user/(.*)/custom/ to the location /var/www/custom I don't know, how to write NginX rules. I tried

location ~* /user/(.*)/custom/ {
   alias /var/www/custom/; 
}

but such rule doesn't work.

Any suggestions please? Thank you

2 Answers 2

1

Well mine was similar to this

location ~* /user/[^/]+/custom/(.*) {
   alias /var/www/custom/$1;
}

Yours suffer from the issue that below will results in the same files

/user/username/abc/test/custom/test.css
/user/username/abc/custom/test.css
/user/username/custom/test.css

Mine will give 404 on first 2 and give you the proper file on last one

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I understand...this is better one. Thank you so much.
0

Ok, so finally I figured it out. The right solution (at least I hope so) is

location ~* /user/(.*)/custom/(.*) {
   alias /var/www/custom/$2; 
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.