title: Runnin magento unde the wordpress as a subdirectory over Nginx
body: <p>I am running magento under the Wordpress(Wordpress on the root and mangento under a subdirectory "/shop"). Previously I was running this under the Apache, So everything was running fine with separate .htaccess under the /shop folder.</p>
  
  <p>As I move the server over NginX, all the internal magento URL showing 404. Please help me to solve this problem. Please suggest me how can I run the Magento under the /shop folder with Wordpress.</p>
  
  <p>Here is my NginX Configuration file:</p>
  
  <pre><code>server {
  listen       80;
  server_name  domain.com www.domain.com;
  
  root   /var/www/html;
  index index.php index.html index.htm;
  
  error_log           /var/www/logs/error.log;
  access_log         /var/www/logs/access.log;
  
  ### gZip Setting ###
  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  ### gZip End ###
  
  location / {
  if ($http_host !~ "^www\."){
       rewrite ^(.*)$ http://www.$http_host/$1 redirect;
      }
      try_files $uri $uri/ =404;
  }
  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
      root /usr/share/nginx/html;
  }
  
  location /shop/ {
      try_files $uri $uri/ /index.php?$args;
  }
  
  location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
      rewrite ^(.*.php)/ $1 last;
  }
  
  if (!-e $request_filename)
  {
      rewrite ^(.+)$ /index.php?q=$1 last;
  }
  
  location ~ .php$ { ## Execute PHP scripts
  
      if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
  
      expires        off; ## Do not cache dynamic content
      fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params; ## See /etc/nginx/fastcgi_params
  }
  </code></pre>
  
  <p>}</p>