Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 2.17 KB

File metadata and controls

45 lines (34 loc) · 2.17 KB

URL Rewrites for WordPress Multisite

When setting up WordPress Multisite the instructions tells you to add URL rewrite rules, but they're for Apache using .htaccess only...

Valet

For Laravel Valet we have created a driver file that you can drop into your ~/.config/valet/Drivers/
(before v2.1.0 Valet drivers path was at ~/.valet/Drivers/)

Homestead

Laravel Homestead's Nginx configuration can be extended using this nifty trick inspired by Otley's comment from this Laracasts thread.

Follow these steps:

  1. Find your homestead scripts directory in your local machine. It may be ~/Homestead/scripts/ or ~/.composer/vendor/laravel/homestead/scripts/ depending on your Homestead installation.

  2. Edit serve-laravel.sh and add include /etc/nginx/conf.d/$1-custom; just above the location ~ \.php$-block and touch "/etc/nginx/conf.d/$1-custom" at the end of the file (or just before service nginx restart - if present).

  3. Reprovision Homestead by running vagrant reload --provision in your homestead directory (where the Vagrantfile is).

  4. SSH into your Homestead box (usually by running vagrant ssh in your homestead directory).

  5. In the Homestead box, cd /etc/nginx/conf.d/ and edit the file therein corresponding to your WordPress Multisite. The WordPress documentation for Nginx gives us the rules to add in the custom rules file:

  if (!-e $request_filename) {
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;
      rewrite ^(/[^/]+)?(/wp-.*) $2 last;
      rewrite ^(/[^/]+)?(/.*\.php) $2 last;
  }
  1. Run sudo service nginx restart within your Homestead box to reload Nginx after adding custom rules.