I’m trying to run a multi domain blog installation with WordPress and Nginx. The last step is to configure some rewrite rules in .htaccess
(apache only) for the webserver. How do I translate this into Nginx rewrite rules?
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]
nginx rewrite rules example for WordPress 3 :
Above is missing a space after the rewrite ^./files/(.(html|jpg|……. you need a space after the $ and before /wp-includes/ms-files.php. Cheers!
This nginx rewrite rules for WordPress have solved my problem perfectly,including changing ex.com/wp-admin to ex.com/wp-admin/.
But i’ve found a bug inside which wasted me several hours as followsï¼
If the static url include
.html
just like/%category%/%post_id%.html
,you have to insted of:Change it to:
Or,u’ll had ‘404 page not found’ error in the content pages!
Instead of:
Change it to:
Allows it to direct
to