PioneerMan
PioneerMan

Reputation: 323

.htaccess on SiteGround doesn't support redirects using encoded spaces in file names?

I'm here after not having success speaking with the tech support at SiteGround.com. I can redirect any file, using proper rules in the .htaccess file, EXCEPT for files that contain a space. This despite the fact that I properly encode any space using %20. Here is the code:

Redirect permanent "/pdf/Adam%20Teachings.pdf" "/pdf/Adam.pdf"

If I am in the /pdf directory on my website, and I click the link for "Adam Teachings.pdf", the web browser then loads "Adam Teachings.pdf" instead of "Adam.pdf". Is this ultimately a problem with the way SiteGround.com has their servers configured? Or am I missing something in this one line of code? Although other posts on stackoverflow talk about spaces in a htaccess file, none of the posts seemed to be my exact situation.

Thank you.

Upvotes: 0

Views: 427

Answers (1)

MrWhite
MrWhite

Reputation: 45968

Redirect permanent "/pdf/Adam%20Teachings.pdf" "/pdf/Adam.pdf"

The mod_alias (not mod_rewrite) Redirect directive matches against the %-decoded URL-path, so unless the space is erroneously doubly encoded in the initial request (ie. as %2520) then you should be matching against a literal space here, not %20.

In other words, it should be:

Redirect permanent "/pdf/Adam Teachings.pdf" "/pdf/Adam.pdf"

Reference:

Upvotes: 0

Related Questions