Redirect all post into some category to url without category

Assuming your URLs are of the form /<category>/<post-name>/ (trailing slash optional) then an .htaccess only solution would look something like the following, at the top of your .htaccess file: # Remove some categories from the URL RewriteRule ^(ricette|svezzamento|alimentazione)/([^/]+)/?$ /$2/ [R=301,L] The $2 backreference (in the RewriteRule substitution) matches the <post-name> from the requested URL. It … Read more

htaccess redirect – replace special character

Try it like this, replacing your existing redirect (which is now the 2nd rule below): # Repeatedly replace all hyphens with %20 – internally RewriteRule ^language/(.*)-(.*) language/$1\%20$2 [N,DPI] # Redirect to query string RewriteRule ^language/(.*) /members/?members_search=$1 [NE,R=301,L] This achieves the hyphen replacement and redirect to query string in just 1 external redirect. No additional redirect … Read more

set up 301 redirect within wp-content/uploads/ directory of a WP site to a new image URL

If this image does not exist then the request will be rewritten to the WordPress front-controller before your redirect occurs. Try the following instead using mod_rewrite at the top of the .htaccess file, before the # BEGIN WordPress code block: RewriteRule ^(wp-content/uploads/2021/09)/image-1\.png$ https://%{HTTP_HOST}/$1/image-2.png [R=302,L] The $1 backreference in the substitution string simply avoids having to … Read more

Use virtual pages point to one specific page

I actually found a rather easy way to achieve this: add_rewrite_rule( ‘city/([a-zA-Z]+)/?$’, ‘wp-content/plugins/csv-to-html/templates/csvtohtmlpage_core.php?city=$1’ ); Yes, I know I did not mention city/ in the beginning but I just wanted wanted to know how should I achieve this. If someone has better ideas. Please tell me! 🙂

htaccess rules not applied?

Your rules are in the wrong order. Your “Custom Redirect” needs to be at the top of the .htaccess file before the WordPress front-controller, ie. before the # BEGIN WordPress comment marker. By placing it after the WordPress code block it will only get processed for requests that map directly to files and directories (including … Read more