Nginx URL Rewrite for Wordpress
Here is a short tutorial and how-to configure nginx and wordpress to support a permalink.
Login into Wordpress dashboard
First, Login into wordpress admin
ex : http://www.domain.com/wp-admin
input your admin user and password
Click Settings
Click Permalink
Enable "Permalink custom"
Add this to permalink custom
%postname%
Save.
Testing it out.
Open your web browser and input this url
http://www.domain.com where domain.com is your wordpress default website
Click About Page and you should receive 404 error.
No problem, next we will configure nginx to support permalink.
$pico /usr/local/etc/nginx/wordpress_params.regular
# WordPress pretty URLs:
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php?q=$1 last;
# Enable nice permalinks for WordPress:
error_page 404 = //index.php?q=$uri;
]
### save this file
Edit Nginx.conf Vhost
#pico /usr/local/etc/nginx/vhost.d/wowtutorial.org.conf
### edit few lines below ###
location /
{
root /home/username/public_html/$blog_directory;
index index.php index.html index.htm;
# this is the file you created above, then populated with content
include wordpress_params.regular;
}
### save this file
Restart nginx web server
#killall -9 nginx
#/usr/local/sbin/nginx start
Recent blog posts |
Recent comments
|
Comments
Thanks. You saved me an
Thanks. You saved me an headache
Thanks
Thanks, spent the day trying to get this figured out. Glad I found your post though you may want to delete the "]" after the first code.
Thanks again.
Post new comment