• I have strange problem with redirection in WordPress. There are two pages with similar permalink:

    https://www.example.com/finance

    https://www.example.com/finance-and-accounting

    After entering on /finance-and-accounting address, WordPress redirects to the /finance page.

    When I change /finance-and-accounting to, for example /123finance-and-accounting it’s work fine, but I need current address. I tought that change current address to something working and add redirect from /finance-and-accounting to new address will good solution but…

    Wordpress root folder don’t have .htacces file, but includes nginx.conf file, so I guess it’s on nginx server. Important – this nginx.conf file was empty.

    I tried add following code to nginx.conf:

    location /finance-and-accounting {
      rewrite ^(.*)$ https://www.example.com/new-address redirect;
    }

    and

    location https://www.example.com/finance-and-accounting {
      rewrite ^(.*)$ https://www.example.com/new-address redirect;
    }

    also
    remove_action('template_redirect', 'redirect_canonical');
    in functions.php

    But it’s not work. It still redirect to /finance page.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Maybe it’s not on Nginx but someone stuffed a Nginx.conf in there for some odd reason or it’s running Nginx as a proxy with Apache running as the webhost.

    Or maybe some other webhost even.

    Or that Nginx, Varnish, Apache lashup.

    Might be a good idea to look real hard, check via the control panel, or call the webhost.

    • This reply was modified 5 years, 12 months ago by JNashHawkins.

    Hi tymekd,

    Can you please setup a .htaccess file at root directory and write below snippet at file and try it? Hope it will work. Please clear cache or test it in incognito mode of browser.

    RewriteCond %{REQUEST_URI} /finance-and-accounting [NC]
    RewriteRule .* https://www.example.com/finance-and-accounting/ [R=301,L]

    RewriteCond %{REQUEST_URI} /finance [NC]
    RewriteRule .* https://www.example.com/finance/ [R=301,L]

    # 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>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Redirection problem with similar URL’s’ is closed to new replies.