title: How to install WordPress alongside Laravel on Nginx with pretty permalinks (SEO-friendly URLs)?
body: <p>I have a Laravel site running on Nginx, and it's fine.</p>
  
  <p>It has a normal folder structure like:</p>
  
  <pre><code>/app
  /public
  /vendor
  ...
  </code></pre>
  
  <p>The <code>/public</code> folder is where the Laravel index.php is.</p>
  
  <p>I've installed WordPress at <code>/public/blog</code> because I want my blog to be visible at <code>mywebsite.org/blog</code>. </p>
  
  <p>The blog currently works fine if I leave the Permalink Settings defined at <code>/blog/wp-admin/options-permalink.php</code> set to "Default" (which means the URLs for posts look like <code>/blog/?p=123</code>).  <strong>If I change Permalink Settings to <code>/blog/%postname%/</code>, I can't view the posts (I get a Laravel 404 page).</strong></p>
  
  <p>I definitely want my blog posts to have SEO-friendly URLs (pretty permalinks).</p>
  
  <p>My current Nginx config is:</p>
  
  <pre><code>server {
      #This config is based on https://github.com/daylerees/laravel-website-configs/blob/6db24701073dbe34d2d58fea3a3c6b3c0cd5685b/nginx.conf and seemed to be necessary to get Laravel working.
      server_name mysite.local;
  
       # The location of our project's public directory.
      root F:/code/mysite/public/;
  
       # Point index to the Laravel front controller.
      index           index.php;
  
      location / {
          # URLs to attempt, including pretty ones.
          try_files   $uri $uri/ /index.php?$query_string;
      }
  
      # Remove trailing slash to please routing system.
      if (!-d $request_filename) {
              rewrite     ^/(.+)/$ /$1 permanent;
      }
  
      # Yoast WordPress SEO plugin says to add these 2 rewrites:
      rewrite ^/blog/sitemap_index\.xml$ /blog/index.php?sitemap=1 last;
      rewrite ^/blog/([^/]+?)-sitemap([0-9]+)?\.xml$ /blog/index.php?sitemap=$1&amp;sitemap_n=$2 last;
  
      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9123
      location ~ \.php$ {
          fastcgi_pass   127.0.0.1:9123;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include        fastcgi_params;
      }
  
      location ~* \.(css|js|gif|jpe?g|png)$ {
          #images, CSS, and JS have 1 week expiration: http://aspyct.org/blog/2012/08/20/setting-up-http-cache-and-gzip-with-nginx/ See also: http://serverfault.com/questions/339240/chromium-audit-says-its-not-caching-static-content-yet-headers-are-set-who-i
          expires 168h;
          add_header Pragma public;
          add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      }
  
  }
  </code></pre>
  
  <p>I have spent hours reviewing other answers (listed below) and haven't figured out how to get this working.</p>
  
  <p>Suggestions?</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/a/10089936/470749">https://stackoverflow.com/a/10089936/470749</a></li>
  <li><a href="https://stackoverflow.com/a/18596822/470749">https://stackoverflow.com/a/18596822/470749</a></li>
  <li><a href="https://stackoverflow.com/a/17816122/470749">https://stackoverflow.com/a/17816122/470749</a></li>
  <li><a href="https://stackoverflow.com/a/12635095/470749">https://stackoverflow.com/a/12635095/470749</a></li>
  <li><a href="https://stackoverflow.com/a/11522602/470749">https://stackoverflow.com/a/11522602/470749</a></li>
  <li><a href="https://stackoverflow.com/a/6155935/470749">https://stackoverflow.com/a/6155935/470749</a></li>
  <li><a href="https://stackoverflow.com/a/23416206/470749">https://stackoverflow.com/a/23416206/470749</a></li>
  <li><a href="http://codex.wordpress.org/Nginx#WordPress_Multisite_Subdirectory_rules" rel="nofollow noreferrer">http://codex.wordpress.org/Nginx#WordPress_Multisite_Subdirectory_rules</a></li>
  <li><a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory" rel="nofollow noreferrer">http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory</a></li>
  <li><a href="https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/in-a-subdirectory/" rel="nofollow noreferrer">https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/in-a-subdirectory/</a></li>
  </ul>
  
  <p>P.S. I'm flexible with where I'd install the WordPress files (e.g. either at <code>/public/blog</code> or move it up a level to <code>/blog</code> or <code>/wordpress</code>).</p>