Using a ~ in the address to link to a WP blog... (8 posts)

  1. RainbearNJ
    Posted 10 years ago #

    I was shown today that, as long as someone uses ~ges, things work fine.. but if, for some reason, like Blogger's codebase, something translates the ~ to %7E, you get a 404 error. I'm confused, as %7E is the encoding *for* a ~. Is there something I can do to have WP recognize this properly? I'm running WP2.0.1 on Apache 2.0.55, and PHP 4.4.2...

    Thanks in advance!

  2. Cypher
    Posted 10 years ago #

    This has nothing to do with WP. You need to configure Apache either using Directory Aliases, or better yet Virtual Hosts.

    Check out the following links for more info:


  3. RainbearNJ
    Posted 10 years ago #

    Hi.. um.. I have the home directory stuff working. Perhaps I wasn't clear.

    The URL is http://www.wingfoot.org/~ges/ this *WORKS*! Honest--it does!

    Now, someone tried to link to me, but their software (Blogger) changes the ~ to a %7E (% 7 E in case it's not showing), and tries to pass that on as the URL. Instead of WP reading the %7E, and going "Oh yeah, that's a ~" it's going "Oh this isn't the right URL, so this is a 404!"

    Hence my original question... Thank you for your reply, however. :)

  4. RainbearNJ
    Posted 10 years ago #

    I'm going to see if I can recreate this:

    http://www.wingfoot.org/~ges/ <--this works
    http://www.wingfoot.org/%7Eges/ <--this doesn't...

  5. Cypher
    Posted 10 years ago #

    I realize that your website works with ~. The problem is that most systems will usually translate things like ~ ( ) and other characters into their ASCII value. Thats just how it works.

    You could just as easily fix this by creating a "virtual host" or a subdomain line ges.wingfoot.org.

    It is generally inadvisable to have "~" in the URL unless you're using the website on an internal network.


  6. RainbearNJ
    Posted 10 years ago #

    I understand your opinion on ~ in URLs. It is, however, the default Userdir behavior on an Apache installation. The %7E and ~ are transparent to Apache--it's specifically WP that is reading %7E and ~ as being different. :-/

    But, I thank you for your reply. I guess I'm going to have to live with WP's behaviour on this for now.


  7. wls
    Posted 9 years ago #

    Was this ever resolved? It's plaguing me as well.

    Basically what I'm seeing happen is that a REQUEST_URI shows up as /%7Ewls/blog/, and while Apache it more than happy to deal with that, WordPress has some brain damage in recognizing that a URL with %7E in it is the same as one with a tilde in it.

    Like you, any links using a tilde work:

    And, like you, any links using the escape encoding do not:

    Obviously Apache is delivering up a WordPress template, meaning it's found the directory. But it's the WordPress code that can't figure out the URL to pull up the correct entries.

    I've tried poking around with mod_rewrite rules as well as WordPress's PHP code. At the moment I'm not having much luck, as I think the page determination code happens well before I get around to fixing the string to a familiar form.

  8. wls
    Posted 9 years ago #

    I came up with a simple one like hack that solved it, see
    http://www.wwco.com/~wls/blog/2006/11/19/wordpress-tilde-hack-for-home-directories/ for more detail.

    The gist is, inside index.php, insert this as the first line within the PHP tags:
    $_SERVER['REQUEST_URI'] = preg_replace( "/%7[Ee]/", "~", $_SERVER['REQUEST_URI'] );

Topic Closed

This topic has been closed to new replies.

About this Topic