Enable WordPress permalinks on Nginx web server.
Edit host’s config file at etc/nginx/sites-enabled
Add the following:
1 2 3 |
location / { try_files $uri $uri/ /index.php$is_args$args; } |
https://ohnorandom.com/blog
, add this code:
1 2 3 4 5 6 |
location /blog/ { index index.html index.php; if (!-e $request_filename) { rewrite ^/blog/(.*)$ /blog/index.php last; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
server { listen 80; server_name ohnorandom.com; root /var/www/ohnorandom.com/; index index.html index.htm index.php; client_max_body_size 32m; access_log /var/www/ohnorandom.com/access.log; error_log /var/www/ohnorandom.com/error.log; autoindex off; # Forbid access to .htaccess location ~ /\.ht { deny all; } # For wordpress installation on subfolder. ie: http://website.com/wordpress location /wordpress/ { index index.html index.php; if (!-e $request_filename) { rewrite ^/wordpress/(.*)$ /wordpress/index.php last; } } location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; # Keep these parameters for compatibility with old PHP scripts using them. fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # Some default config fastcgi_connect_timeout 20; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_pass 127.0.0.1:9000; #fastcgi_pass unix:/var/run/php5-fpm.sock; } } |