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?

4
  • 2
    your server does this.
    – Milo
    Commented Feb 10, 2014 at 20:08
  • We are using nginx. Lemme see if I can find a directive in there.
    – Nathan
    Commented Feb 10, 2014 at 20:38
  • So far, it looks like that trailing slash can only be removed doing a redirect.
    – Nathan
    Commented Feb 10, 2014 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
    Commented Mar 11, 2015 at 19:32

1 Answer 1

-1

add this line to functions.php

remove_filter('template_redirect', 'redirect_canonical');

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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