2

I am using Wordpress for a "news" section on a e-commerce site. So the root of the wordpress install is in a sub-folder.

www.mysite.com/news

I have setup the home & site URL to reflect this in the admin. I also make sure there are no trailing slashes in the permalinks. However, it keeps doing a 301 redirect and forcing a trailing slash so it looks like:

www.mysite.com/news/

I even tried to force it in the wp-config.php file, defining the WP_HOME and WP_SITEURL parameters. I cannot for the life of me figure out where this is happening. I don't mind creating a small PHP function to rewrite this url (without any kind of redirect).

Ideas?

  • 2
    your server does this. – Milo Feb 10 '14 at 20:08
  • We are using nginx. Lemme see if I can find a directive in there. – Nathan Feb 10 '14 at 20:38
  • So far, it looks like that trailing slash can only be removed doing a redirect. – Nathan Feb 10 '14 at 20:55
  • Check out Settings > Permalinks and make sure there is no trailing slash on the option chosen. You may have to choose the custom structure option and then copy the structure you want, without the trailing slash of course. – kel Mar 11 '15 at 19:32
-2

add this line to functions.php

remove_filter('template_redirect', 'redirect_canonical');

and don't forget clear cache or test on clean browser

  • 1
    Please add an explanation to your answer: why could that solve the problem? Are there any side-effects? – fuxia Apr 13 '15 at 14:16
  • This this line you can fix redirect from domain.com/page to domain.com/page/ with trail slash – Nerjuz Apr 14 '15 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.