user2727837 user2727837 - 5 months ago 15
PHP Question

wordpress site work on local but not works on online server

my wordpress site correctly working on local server but when i am uploading it on server 404 page not found error is showing.

i check my index.php its correctly redirecting.
here is code:-

<?php

define('WP_USE_THEMES', true);

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


i check my wp-blog-header.php,its also working.because i forward it to phpinfo page and info page showing,but site page not showing.
here is wp-blog-header code:-


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' );
}
?>


and my temp-loader.php is:-

<?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;
?>


and my htaccess file is:-

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>


plz tell me how i run my site online.

Answer

This is a really frustrating problem when using WordPress indeed. But I'll try to share some experiences I had.

0) Enable debugging mode: In wp-config.com change WP_DEBUG to TRUE and add the following lines:

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

With this, we'll have WP showing up more errors than we want ;)

tip: use it in local machine to make a bulletproof plugin/theme/project

1) Check if the 404 is from the default browser or from wordpress: Try to access wp-admin url. This is a good way to check if the domain is properly set. Sometimes the error is that index.php is not being found, so, we need to load something that will not care for the plugins and themes, that's the reason I suggest to use the wp-admin.

tip: Even a theme-less install, will have the wp-admin working

2) Remove anything that can be the problem: If we can't find exactly what's wrong on previous steps, we need to get dirty: rename the THEMES and PLUGINS folders to ensure that the problem isn't any of the plugins.

tip: sometimes a blank line in the beginning of a plugin file can break completly your project

3) Give a link: I can't comment yet, but I'll be glad on helping you if you send me a link to see the error.