【问题标题】:Access WordPress site running on localhost through localtunnel通过 localtunnel 访问在 localhost 上运行的 WordPress 站点
【发布时间】:2012-08-23 19:43:22
【问题描述】:

我通过 localtunnel (http://progrium.com/localtunnel/) 共享静态站点没有问题,但我似乎无法使 WordPress 站点工作。

我的本​​地 WordPress 站点在 MAMP 服务器上运行,没有任何问题。

我也不确定是什么问题。我认为这可能与无法访问 MySQL 数据库有关?

谁能告诉我如何通过 localtunnel 访问在 localhost 上运行的 WordPress 站点?

感谢阅读。

【问题讨论】:

    标签: wordpress localhost share local tunnel


    【解决方案1】:

    我在 localtunnel 方面没有大量经验,但 Forward 确实支持 WordPress,并且有一个关于如何使其工作的常见问题解答:https://forwardhq.com/support/faq#how-do-i-use-forward-with-wordpress,它可能会帮助您追踪您的问题......或者至少给出你是另一个选择。

    【讨论】:

      【解决方案2】:

      把它放在你的 wp-config 中:

      /* THIS IS CUSTOM CODE CREATED AT ZEROFRACTAL TO MAKE SITE ACCESS DYNAMIC */
      /* WORKS FOR LOCALTUNNEL!!!!!! */
      
      $currenthost = "http://".$_SERVER['HTTP_HOST'];
      $currentpath = preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME']));
      $currentpath = preg_replace('/\/wp.+/','',$currentpath);
      define('WP_HOME',$currenthost.$currentpath);
      define('WP_SITEURL',$currenthost.$currentpath);
      define('WP_CONTENT_URL', $currenthost.$currentpath.'/wp-content');
      define('WP_PLUGIN_URL', $currenthost.$currentpath.'/wp-content/plugins');
      define('DOMAIN_CURRENT_SITE', $currenthost.$currentpath );
      define('ADMIN_COOKIE_PATH', './');
      define('FS_METHOD', 'direct');
      define( 'WP_ENVIRONMENT_TYPE', 'local' );
      

      我在没有 WP_CONTENT_URL、WP_PLUGIN_URL 和 ADMIN_COOKIE_PATH 的情况下成功使用了它,但将它们包括在此处是因为它们位于此处的原始代码中:https://wordpress.stackexchange.com/questions/179559/relative-or-dynamic-site-url-possible

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-06-02
        • 1970-01-01
        • 2014-02-27
        • 2018-06-08
        • 1970-01-01
        • 2014-03-15
        • 2011-01-24
        • 2018-11-12
        相关资源
        最近更新 更多