使用wordpress作为drupal安装的子目录?

我使用NginX 0.7.65运行Ubuntu 10.04。

我有Drupal安装在根目录下,它适用于一个适当configuration的虚拟主机文件,但现在我想要安装Wordpress在同一个域的子目录。 当我去example.com/wordpress时,它会导致404错误,并由Drupal处理。 这是我的虚拟主机文件:

server { server_name www.example.com example.com; access_log /srv/www/example.com/logs/access.log; error_log /srv/www/example.com/logs/error.log; root /srv/www/example.com/public_html; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # This matters if you use drush location = /backup { deny all; } # Very rarely should these ever be accessed outside of your lan location ~* \.(txt|log)$ { allow 192.168.0.0/16; deny all; } location ~ \..*/.*\.php$ { return 403; } location / { # This is cool because no php is touched for static content try_files $uri @rewrite; } location @rewrite { # Some modules enforce no slash (/) at the end of the URL # Else this rewrite block wouldn't be needed (GlobalRedirect) rewrite ^/(.*)$ /index.php?q=$1; } location ~ \.php$ { include conf-inc.d/fastcgi.conf; track_uploads uploads 60s; } # The Nginx module wants ?X-Progress-ID query parameter so # that it report the progress of the upload through a GET # request. But the drupal form element makes use of clean # URLs in the POST. location ~ (.*)/x-progress-id:(\w*) { rewrite ^(.*)/x-progress-id:(\w*) $1?X-Progress-ID=$2; } # Now the above rewrite must be matched by a location that # activates it and references the above defined upload # tracking zone. location ^~ /progress { report_uploads uploads; } # Fighting with ImageCache? This little gem is amazing. location ~ ^/sites/.*/files/imagecache/ { try_files $uri @rewrite; } # Catch image styles for D7 too. location ~ ^/sites/.*/files/styles/ { try_files $uri @rewrite; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; } # Deny access to Apache .htaccess files. location ~ /\.ht { deny all; } } 

从类似的线索回答灵感

问题是这个php-fallback的位置指令

 location / { # This is cool because no php is touched for static content try_files $uri @rewrite; } location @rewrite { # Some modules enforce no slash (/) at the end of the URL # Else this rewrite block wouldn't be needed (GlobalRedirect) rewrite ^/(.*)$ /index.php?q=$1; } 

有了这个configuration,你可以将所有的请求重写到drupal index.php,包括你的wordpress文件。 解决scheme是定义一个位置块来处理wordpress的php-fallback

 location /wordpress { index index.php index.html index.htm; try_files $uri $uri/ /wordpress/index.php; } 

在这个位置你重写所有的请求wordpress index.php。