Forums

Directly accessing theme folder shows fatal error (11 posts)

  1. Jason_333
    Member
    Posted 2 years ago #

    Hi,

    Whenever I type http://mysite.com/wp-content/themes/theme_name/

    I get a fatal error. I noticed that almost all wordpress installations shows the same error. Try it on yours. Is there anyway to prevent this error from showing. These two (big) websites using wordpress have somehow prevented it:

    http://mashable.com
    http://popcrunch.com

  2. jceresini
    Member
    Posted 2 years ago #

    You're seeing the following error most likely:

    Fatal error: Call to undefined function get_header() in [path]/index.php on line 7

    This is because the themes are not meant to be accessed directly. They are loaded by wordpress. What are you trying to accomplish? There may be another way to do it.

    [signature moderated Please read the Forum Rules]

  3. Jason_333
    Member
    Posted 2 years ago #

    You're right jceresini, that is the error I see. I'm not trying to accomplish anything, I just don't want the error because in Godaddy hosting one's account username appears in the error path like so.

    Fatal error: Call to undefined function query_posts() in /home/content/a/b/c/USERNAME/html/wp-content/themes/theme_name/index.php on line 1

    This may not be that big of a security threat but it still does reveal one's account username. So it would be nice if I could prevent this error message from showing and possibly all other error messages as well.

  4. jceresini
    Member
    Posted 2 years ago #

    I see. If you disable "display_errors" in your php.ini file this error message will be suppressed and that page should return a blank document

  5. Jason_333
    Member
    Posted 2 years ago #

    I was reading about the php.ini file this morning but unfortunately my economic hosting plan doesn't allow me access to it. I was hoping there was some other way of suppressing errors but perhaps there isn't :(

  6. jceresini
    Member
    Posted 2 years ago #

    Your host may not let you modify the php.ini file, but they should be willing to turn off "display errors" for you. Who do you host with?

  7. Jason_333
    Member
    Posted 2 years ago #

    Godaddy, right now I'm just on a economic plan until I finish building my site. I will soon be getting a dedicated server. I'm sure I will have control over the php.ini file then, if not I will ask them to turn off display errors for me. I saw some PHP snippets posted on the web that are supposed to prevent error messages but I could mever get them to work and I'm pretty sure it can't be done with htaccess. So I'll just have to do it the php.ini way I guess. Thanks.

  8. Samuel B
    moderator
    Posted 2 years ago #

  9. jceresini
    Member
    Posted 2 years ago #

    Actually, that won't work. If they're accessing the theme pages directly its not going to parse the wp-config.php. You can, however, place

    @ini_set('display_errors','Off');

    in each of your theme files. Thats a bit intrusive though

  10. Jason_333
    Member
    Posted 2 years ago #

    Wow this does actually work:

    <?php @ini_set('display_errors','Off'); ?>

    I wonder why it only works if I put it in template files and not when I just put it in header.php. After all, all my template files have a call to the header in them. Buy yeah, putting it in each file is a bit too much.

  11. Jason_333
    Member
    Posted 2 years ago #

    samboll thanks, I never knew errors could be suppressed using wp-config. I added the bit of code from the codex and it did suppress errors, not for directly accessed files but still very helpful.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.