Can this code cause a "500" internal server error ?
Posted
by Scott B
on Stack Overflow
See other posts from Stack Overflow
or by Scott B
Published on 2010-03-30T15:31:19Z
Indexed on
2010/03/30
15:33 UTC
Read the original article
Hit count: 283
A few of my customers are reporting that they are getting "500" Internal Server errors lately. I believe it might be caused by various plugins they are using but each time, the hosting company (multiple hosts) are saying that the htaccess file had to be replaced to fix the issue.
I'm submitting the code below from my custom theme because its the only place where I trigger an htaccess write. And I want to be sure that there are no problems here that could cause an issue that might contribute to the 500 errors...
if (file_exists(ABSPATH.'/wp-admin/includes/taxonomy.php'))
{
require_once(ABSPATH.'/wp-admin/includes/taxonomy.php');
if(get_option('permalink_structure') !== "/%postname%/" || get_option('mycustomtheme_permalinks') !=="/%postname%/")
{
$mycustomtheme_permalinks = get_option('mycustomtheme_permalinks');
require_once(ABSPATH . '/wp-admin/includes/misc.php');
require_once(ABSPATH . '/wp-admin/includes/file.php');
global $wp_rewrite;
$wp_rewrite->set_permalink_structure($mycustomtheme_permalinks);
$wp_rewrite->flush_rules();
}
if(!get_cat_ID('topMenu')){wp_create_category('topMenu');}
if(!get_cat_ID('hidden')){wp_create_category('hidden');}
if(!get_cat_ID('noads')){wp_create_category('noads');}
}
if (!is_dir(ABSPATH.'wp-content/uploads')) {
mkdir(ABSPATH.'wp-content/uploads');
}
© Stack Overflow or respective owner