Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having a bit of a trouble with nginx and rewriting. Searching on the internet only shows results for rewriting domains or changing request_uri's, but I'm trying to rewrite part of the uri.

Whenever a client connects to site.com it should go to site.com/en but when it connects to site.nl it should go to site.nl/nl (both on the same root files). They're both in their own server block, with the following rewrite rule:

rewrite ^ /en/$request_uri;

This one doesn't really work and also rewrites all the paths to the css and images. Now the biggest problem is probably that there's already a drupal rewrite:

if (!-e $request_filename) {
  rewrite ^/(.*)$ /index.php?q=$1 last;

Is there any way to combine these or another way to let the user go to the correct url with /en or /nl? Or would this work in Apache?

Edit: I ended up using apache, since that has a simple redirect:

RewriteEngine On
RedirectMatch permanent ^/$ /en
share|improve this question
What do you want with css and images? Could you please elaborate more details? –  quanta Sep 22 '11 at 16:44
the css is normally on /sites/default/files, but this also rewrote it to /en/sites/default/files, so those would be inaccesible. Regardless, I went with apache –  XSlicer Sep 26 '11 at 11:23
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.