douduan1953 2010-03-30 15:31
浏览 40

此代码是否会导致“500”内部服务器错误?

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

The code first checks to make sure taxonomy.php is present, since the wp_create_category calls require it. It also checks the existing permalink settings and if they are not set according to my anticipated parameters, I execute the permalink rewrite code you see there. Its this code that, I'm fairly certain, creates an htaccess edit. I want to be sure that this is a sound bit of programming and not likely to cause sporadic internal server errors...

EDIT: In One Case, the user has the following plugins in all his sites...

  • AIO SEO
  • cbnet ping optimizer
  • contact form 7
  • easy privacy policy
  • Exec-PHP
  • Free Traffic Getting SEO Plugin
  • google sitemap generator
  • pretty link
  • ReviewAZON
  • Sociable
  • StatPress ReLoaded
  • Web Traffic Genius Pro
  • WP DB Backup
  • 写回答

1条回答 默认 最新

  • doubeishuai6598 2010-03-31 12:44
    关注

    The mkdir call will definitely fail if wp-content is not writable, the same goes for the permalink edit - if .htaccess is not writable then it will fail and might cause a 500 error (depending on how Wordpress implements this). Another possible problem could be that your .htaccess changes corrupt some other setting in .htaccess that is needed by one of the other plugins.

    In any case : looking at the Apache error log and logging PHP errors should be enough to find the actual source of the problem.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?