• Resolved jeffpurcell

    (@jeffpurcell)


    When developing a new WordPress website, we use the temporary cPanel URL. Something that resembles this:

    https://192.168.0.1/~username

    We do this so we can develop inside the same cPanel account and quickly launch the site by changing the WP_SITEURL and WP_HOME and running a quick search and replace in the db.

    My issue comes when saving a post, page or any cpt. After saving or publishing the new url after saving looks like this:

    https://192.168.0.1/wp-admin/post.php?post=7161&action=edit

    It is missing the ~username portion of the url.

    I’ve even defined the WP_HOME and WP_SITEURL constants to include the full path:

    https://192.168.0.1/~username

    From poking around on other forums I’m beginning to think this may be a url sanitizing function.

    Any one have a thought on how to avoid this?

    The post saves just fine, but it is quite annoying to have to edit the url after every save.

    • This topic was modified 7 years, 4 months ago by jeffpurcell.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    It won’t work because the tilde is handled specially. If you can modify the Apache2 config and create an explicit <Directory /> section for your directory then it should work.

    You may be able to do that in cPanel too.

    Thread Starter jeffpurcell

    (@jeffpurcell)

    I’ve found (possibly) a simpler method. The get_post_link filter seems to do the trick:

    add_filter( 'get_edit_post_link', 'my_edit_post_link' );
    
    function my_edit_post_link() {
    	 return WP_HOME . "/wp-admin/post.php?post=".$post->ID."&action=edit";
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tilde in WP_HOME Throws 404 When Saving Post’ is closed to new replies.