WordPress: Trailing slashes

When i downloaded a site, noticed that i was getting this when i clicked on some pages

I went a head a started digging and realized that wordpress was redirecting over and over and over again. 

I put in a pf call at the beggining of werm.php and it stopped the redirect, so it let me know it was wordpress doing the redirect not nginx. 

Now i know that in order to do a redirect you would use header(“Location:….

I did a search on google for wordpress redirect and found this

So i went to this file and commented out

And it stopped redirecting, but it was giving me a blank page

I went ahead and called pf right before this line to see the backtrace. I saw that a file called was calling a function  called

I opened up this file but from another site i was building and went down the function and kept putting in pf(“sdkfgjsd”) randomly down the function until i saw it was’nt working. I found that at line 

So i started to pf $redirect_url and i got false 

meaning not to redirect im assuming. So i went to the site that was giving me this problem and i did the same thing on the same line and got a url

So now i move up and keep outputing $redirect_url until its false

No i pf([$compare_original, $compare_redirect])

Notice how the trailing slashes are not the same, it is then where the redirect_url is given a value and the page gets re directed.

For the site thats working i get this

This was the url i was typing in 

https://dominicanwriters.selectiont.com/shop

With no trailing slash

But somewhere in wordpress it added one.

I looked at the function and optically search for anything that stands out in terms of slashes and found this

I did a search through the build folder for “function user_trailingslashit” and found it in this file

This line gave me the impression that its a setting set by admin. So i did a google search for use_trailing_slashes

I then realized that the size that was working did’nt have trailing slashes, And my nginx conf for the site that was redirecting was’nt adding trailing slashes to the request-uri

The site that was redirecting did have one

Once i took the trailing slash off the site stopped redirecting. But i wanted to keep the sites settings intact and adapt to it, not have it adapt to me. 

When i added a trailing slash to line 36, everything worked. I found out through the datbase i can see this option

If i can read it from here and then write the slash in on my nginx file, then we good.

Leave a Reply

Your email address will not be published.