Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a WordPress site hosted on a Go Daddy server running Apache. My experience is on Windows IIS, so this might be an easy question, but I can't figure it out. I want to allow URLs at my site like:

http://my.site.com/biz/Jordan's_place/jordan/

The problem is two fold.

1) If I enter

http://my.site.com/biz/Jordan's_place/jordan/

the URL is fine, but if I enter:

http://my.site.com/biz/Jordan's_place/jordan

the URL is rewritten to:

http://my.site.com/biz/Jordans_place/jordan/

Note the lost single quote is shown in the browser address.

2) The page requires memebr acce3ss. When you browse to it without logging in you are sent to the login page with the URL

/wp-login.php?redirect_to=/biz/Jordan\'s_place/jordan/

Note the added backslash and then after login the page goes to:

http://my.site.com/biz/Jordans_place/jordan/

Is it WordPress or the server that is messing with the single quotes? Am I crazy to want to allow single quotes in my URLs? If so, why doesn't PHP or javaScript encode them?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Wordpress will strip off special characters, since they can cause issues when writing to the database. It's best practice to avoid using special (reserved) characters in URLs, as they can and will break when passing them around. Case in point, see your own post and the cutting off of the URL after the '.

share|improve this answer
    
so you think I should escape them? –  mrjrdnthms Feb 29 '12 at 3:57
1  
If you absolutely must have the apostrophes in them, then yes you should escape them. However, you are almost guaranteed to run into problems down the road if using any of these characters: < > " ' & - most notably in your sitemap, as they're not valid XML and will cause spiders to report the page as a 404. I can't stress enough to avoid using them if at all possible. –  SickHippie Feb 29 '12 at 7:02
    
Would it be ok to have urls like: my.site.com/biz/Jordan%27s_place/jordan ? –  mrjrdnthms Feb 29 '12 at 21:33
2  
That should be just fine, since the percent encoding would be translated properly by both browser and server - this way even if it's passed around as a link, it will still be valid no matter what. –  SickHippie Feb 29 '12 at 22:42
1  
Thanks for pointing me in the right direction. This worked for me. –  mrjrdnthms Mar 1 '12 at 19:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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