WordPress blog posts permalinks giving 404 on nginx

You should use the ^~ prefix on the location statement, change the alias statement to root /var/www;, and change the last parameter of the try_files statement. For example: location ^~ /blog/ { autoindex on; root /var/www; index index.php; try_files $uri $uri/ /blog/index.php?$args; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } }

AWS WordPress Install – pages/posts 404 on restart until updating permalinks

This answer was based off the comment from @Rup on the question. I needed to add a .htaccess file to my source. I did this with the default contents: # BEGIN WordPress RewriteEngine On RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # … Read more

Changed permalink structure. Need help with redirecting old posts

…it redirected the old URLs to the new URLs without the end trailing slash and then redirected again with the trailing slash. So, it generated 2 redirects instead of one. RedirectMatch 301 ^/([^/]+)/([0-9]{4})/([0-9]{2})/([^/]+)/$ https://www.example.com/$4 In that case you should simply be able to append a trailing slash to the target URL in the above directive … Read more

Redirect parent taxonomy to it’s child

Assuming state and city are variable path segments, so you are essentially redirecting /investments/<one>/<two>/ to /investments/<two>/ then try the following at the top of your .htaccess file: # Redirect “/investments/<one>/<two>/” to “/investments/<two>/” RewriteRule ^(investments)/[^/]+/([^/]+)/$ /$1/$2/ [R=302,L] If you need any further explanation then just ask in comments. UPDATE: I’ve added an end-of-string anchor ($) to … Read more

custom permalinks based on taxonomies for custom post type

Permalink structure is a hierarchy, each level should be descendent of one another, be more specific i.e. shop.com/products/books/fiction/harry-potter where every book is a product, fiction is a genre of books and Harry Potter belongs to fiction books. So in your example product/manufacturer/brand/model every brand should belong to a single manufacturer and every model to a … Read more

How to link to current post in WordPress?

This is exactly the type of scenario shortcodes are intended for. Simply add the following to your theme’s functions file to create the shortcode: add_shortcode( ‘this_permalink’, ‘this_permalink’ ); function this_permalink($atts, $content){ return ‘<a href=”‘. get_the_permalink() .'”>Link to this article</a>’; } .. and use this in your post to render the link: [this_permalink] I cannot think … Read more

Debugging permalink issue

OK fixed it! I had some errant lines in the .htaccess file: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # WP REWRITE LOOP END This was taking precedence over the <IfModule mod_rewrite.c> block – and explains why it was redirecting to the parent directory. (The lesson here is if you are asking … Read more