wp_redirect does not work

The only thing wp_redirect() is adding HTTP header to the current request. It doesn’t prevent request from proceeding to further loading page and must be followed by exit statement to work correctly.

htaccess redirects and WordPress

The standard WordPress .htaccess file will do this for you if you select one of the “pretty permalinks” in the Settings / Permalinks page, like the “posts” option. # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress … Read more

Migrating from http to https

Other answer to this question is the direct way to corrupt database if it contains links in serialized data (and most of modern themes do this). WordPress keeps all internal links as absolute. (If your main page contains link to let say contacts page, in database it is stored as http://example.com/contacts.php). If such a links … Read more

Why does wp_redirect strip out %0A (url encoded new line character) and how do I make it stop?

If you take a look to the wp_sanitize_redirect() function you will notice it is removing the new lines from the destination URL: https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/pluggable.php#L1249 In my opinion you have 2 options: 1 – Convert new lines on the message to a diff allowed unique char combination and then replace them back to new lines before outputting … Read more

Use htaccess to redirect WordPress to static website in a subfolder

If you want an external redirect from /2016/<anything> to /2016/a/<anything>, then you can do something like the following before the existing WordPress directives (ie. before # BEGIN WordPress) in your /2016/.htaccess file: RewriteCond %{REQUEST_URI} ^/(\d{4})/(.*) RewriteRule !^a/ /%1/a/%2 [R,L] The negated RewriteRule pattern prevents the redirect from occurring when the URl-path already starts with a/ … Read more