个性化阅读
专注于IT技术分析

wordpress网站只能在本地工作,而不能在在线服务器上工作

我的wordpress网站在本地服务器上正常工作, 但是当我在服务器404页面上将其上传时, 未找到错误。

我检查我的index.php正确重定向。这是代码:-

      <?php

       define('WP_USE_THEMES', true);

       /** Loads the WordPress Environment and Template */
         require('./wp-blog-header.php');
             ?>

我检查了我的wp-blog-header.php, 它也可以正常工作。因为我将其转发到了phpinfo页面和info页面, 但没有显示网站页面。这是wp-blog-header代码:-

             if ( !isset($wp_did_header) ) {

       $wp_did_header = flase;

  require_once( dirname(__FILE__) . '/wp-load.php' );

wp();

//wp_redirect( ABSPATH . WPINC . '/template-

          loader.php' , 301 );
                    // exit;
                require_once( ABSPATH . WPINC . '/template-loader.php' );
          }
          ?>

而我的temp-loader.php是:-

       <?php
      /**
     * Loads the correct template based on the visitor's url
        * @package WordPress
       */
    if ( defined('WP_USE_THEMES') && WP_USE_THEMES )
do_action('template_redirect');

     // Halt template load for HEAD requests. Performance bump. See #14348
       if( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) )
exit();

       // Process feeds and trackbacks even if not using themes.
       if ( is_robots() ) :
do_action('do_robots');
return;
    elseif ( is_feed() ) :
do_feed();
return;
       elseif ( is_trackback() ) :
include( ABSPATH . 'wp-trackback.php' );
return;
         endif;

    if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
$template = false;
if     ( is_404()            && $template = get_404_template()            ) :
elseif ( is_search()         && $template = get_search_template()         ) :
elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
elseif ( is_front_page()     && $template = get_front_page_template()     ) :
elseif ( is_home()           && $template = get_home_template()           ) :
elseif ( is_attachment()     && $template = get_attachment_template()     ) :
    remove_filter('the_content', 'prepend_attachment');
elseif ( is_single()         && $template = get_single_template()         ) :
elseif ( is_page()           && $template = get_page_template()           ) :
elseif ( is_category()       && $template = get_category_template()       ) :
elseif ( is_tag()            && $template = get_tag_template()            ) :
elseif ( is_author()         && $template = get_author_template()         ) :
elseif ( is_date()           && $template = get_date_template()           ) :
elseif ( is_archive()        && $template = get_archive_template()        ) :
elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
elseif ( is_paged()          && $template = get_paged_template()          ) :
else :
    $template = get_index_template();
endif;
if ( $template = apply_filters( 'template_include', $template ) )
    include( $template );
return;
       endif;
         ?>

我的htaccess文件是:

    Options +FollowSymlinks
      RewriteEngine on
         # BEGIN WordPress
       <IfModule mod_rewrite.c>
          RewriteEngine On
         RewriteBase /
         RewriteCond %{REQUEST_FILENAME} !-f
           RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
        </IfModule>
        # END WordPress


    # PROTECT WP-CONFIG 
        <Files wp-config.php> 
           order Allow, Deny 
          Deny from all
           </Files>

请告诉我我如何在线运行我的网站。


#1


当确实使用WordPress时, 这确实是一个令人沮丧的问题。但我会尝试分享一些经验。

0)启用调试模式:在wp-config.com中, 将WP_DEBUG更改为TRUE并添加以下几行:

error_reporting(E_ALL);
ini_set('display_errors', true);

有了这个, 我们将让WP显示比我们想要的更多的错误;)

提示:在本地计算机上使用它来制作防弹插件/主题/项目

1)检查404是来自默认浏览器还是来自wordpress:尝试访问wp-admin网址。这是检查域设置是否正确的好方法。有时错误是找不到index.php, 因此, 我们需要加载一些不适合插件和主题的内容, 这就是我建议使用wp-admin的原因。

提示:即使没有主题的安装, 也可以使用wp-admin

2)删除可能是问题的所有内容:如果在上一步中找不到确切的问题, 则需要弄清楚:重命名THEMES和PLUGINS文件夹, 以确保问题不出在任何插件上。

提示:有时, 插件文件开头的空白行会完全破坏你的项目

3)提供链接:我目前无法发表评论, 但是如果你向我发送链接以查看错误, 我们将很乐意为你提供帮助。


#2


将wordpress网站从本地服务器迁移到实时服务器时。我们需要考虑以下步骤:

  1. wp-config.php中的数据库配置
  2. 网站网址:如果你正在开发woocommerce网站, 那么我们可以手动更改整个数据库中的网站网址。因此, 有更好的解决方案来搜索和替换脚本。以避免404问题。
  3. 将此脚本放在根文件夹中, 并用新的url替换旧的url。
赞(0)
未经允许不得转载:srcmini » wordpress网站只能在本地工作,而不能在在线服务器上工作

评论 抢沙发

评论前必须登录!