Expected Reading Time: 5 minutes

Maybe you have the same problem as I had some time ago. When deleting posts or drafts, WordPress always threw me back to my start page instead of landing in the post overview. I also had the same problem when deleting plugins. Deleted WordPress plugin and then ended up on the home page. This can be frustrating, especially if you don't know what's causing it and how to fix it. In this blog article, I explain the causes of this problem and offer a detailed solution.

Causes of the problem

The problem occurs if the HTTP header referrer policy of WordPress is not configured correctly or is missing. The referrer header plays an important role on the web as it tells the server which page the user came from. WordPress uses this information to verify user actions such as deleting a post.

If the referrer policy is not set correctly, WordPress cannot verify the origin of the request. As a result, WordPress rejects the request for security reasons and redirects the user back to the start page.

Solution: Setting the header referrer policy

Fortunately, the solution to this problem is relatively simple and requires setting the header referrer policy on your WordPress website. Here are the steps:

  1. Access to the .htaccess fileThis file is located in the root directory of your WordPress installation. You can access it by connecting to your server via FTP or by using the file manager in your hosting control panel.
  2. Adding the referrer policy headerAdd the following line to your .htaccess file: Header set Referrer-Policy "origin-when-cross-origin"
    This setting allows WordPress to correctly identify the referrer without compromising your website security.
  3. Saving and testingAfter you have saved the changes, clear your browser cache and test whether the problem has been resolved. Try moving a post to the trash to see if you are still redirected to the home page.

Another, more global option, which works in any case, is to specify this header directly in the reverse proxy. This means in NGINX, NGINX Proxy Manager or Traefik or even Caddy.

Example NGINX Proxy Manager

  1. Access to the NGINX Proxy Manager:
    • Open the web interface of the NGINX Proxy Manager by entering the corresponding URL in your web browser.
  2. Selecting the host:
    • Go to the list of hosts by clicking on "Hosts" and then on "Proxy Hosts" in the sidebar.
    • Search for the host to which you want to connect the Referrer policy header and click on the 3 dots and then on the Edit button (often shown as a pencil icon).
  3. Editing the host settings:
    • You will find various options in the host settings. Navigate to the "Advanced" section.
  4. Adding the custom header:
    • Add here the Referrer policy header. In the input field for the header name, enter Referrer policy and enter the desired value in the value field, e.g. origin-when-cross-origin.
      Save the changes by clicking on the Save or Apply button.
location / {
    add_header Referrer-Policy "origin-when-cross-origin" always;
}

Checking the configuration:

After you have saved the changes, it is advisable to check the configuration. You can do this by visiting the website and checking the HTTP headers. This can be done via developer tools in your browser or via online header analysis tools. One of these is https://securityheaders.com/.

Additional tips

  • Safety aspects: Please note that the setting of the Referrer policy headers can have an impact on the security and data protection of your website. Choose a value that best suits your security requirements.
  • Browser cache: Don't forget to clear your browser cache or use an incognito mode to make sure you see the latest version of your website.
  • NGINX restartIn some cases, it may be necessary to restart the NGINX service for the changes to take effect.

Conclusion

Setting the header referrer policy is an effective solution to the problem of trash redirection on the WordPress home page. This customization can not only solve the specific problem, but also improve the overall functionality and security of your website.

If you still encounter problems after making these changes, it may be helpful to check your WordPress installation or consult an expert. Remember that regular maintenance and paying attention to security aspects are crucial for the smooth operation of your WordPress website.

Source: https://wordpress.org/support/topic/trashing-a-post-or-page-works-but-returns-to-home-page/

Categories: Tips & TricksWordPress

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_US