Adding some PHP code to Genesis theme functions.php causes 403 Forbidden error

Community Forums Forums General Discussion Adding some PHP code to Genesis theme functions.php causes 403 Forbidden error

This topic is: resolved

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  aristo 7 months, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #105119

    aristo
    Member
    Post count: 8

    I have an issue which official support cannot currently answer. I am wondering if anyone else has come across something similar?

    I have been using the WordPress editor to update functions.php on the Genesis Sample child theme but when I try to save the updates by clicking on the Update File button I get error 403 Forbidden – Access to this resource on the server is denied!

    I have successfully added the same code on a different WordPress installation. This installation is using a free theme. I have tested two code snippets and both cause error on the Genesis Sample child theme installation , however they both work on my other WordPress installation, which makes me think that there is an issue with Genesis Sample child theme.

    It can’t be file permissions as I have made many updates previously to functions.php.

    All my testing points to Genesis. I have 5 themes on my WordPress installation. They are:

    Genesis Sample
    Genesis
    Twenty Fourteen
    Twenty Thirteen
    Twenty Twelve

    I tested adding the same code that was causing the 403 Forbidden error to all of theme’s functions.php The only ones that failed were the two Genesis themes Genesis Sample and Genesis. Therefore I assume the issue lies with Genesis.

    I have double checked the file permissions. Everything is the same across all 5 themes (see evidence of this at File Permission Screen Grabs).

    I have uploaded a video that shows the issue in action:
    Screen Capture Video

    I can successfully add the following (therefore nothing is wrong with the file permissions):

    function my_custom_rewrites() {
     add_rewrite_rule(
     'index.php?image=$matches[1]&comms=$matches[2]&commz=$matches[3]',
     'top' );
    }

    But I cannot add

    function my_custom_rewrites() {
     add_rewrite_rule(
     '^/?database/([0-9]+)/?([a-zA-Z0-9_-]*)/?([a-zA-Z0-9_-]*).html',
     'index.php?image=$matches[1]&comms=$matches[2]&commz=$matches[3]',
     'top' );
    }

    For some reason the editor doesn’t like this line:
    '^/?database/([0-9]+)/?([a-zA-Z0-9_-]*)/?([a-zA-Z0-9_-]*).html',

    The line works on other installations. I also have tested it on a normal PHP test page and it is definitely legitimate PHP code.

    Any help will be much appreciated thank you.

    #105131

    nutsandbolts
    Keymaster
    Post count: 3202

    Have you tried editing functions.php via FTP? I was just able to add that function to a test site via FTP and it worked just fine. In general, I wouldn’t recommend using the WP editor for functions.php – I only use it for quick stylesheet edits.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #105133

    aristo
    Member
    Post count: 8

    I can edit functions.php via FTP and the website works as expected. This is how I have been making my updates to functions.php, but I wanted to know why I was getting the error I was getting. I am new to WordPress and it is annoying me that simple things are not working and I cannot understand why. OK I will avoid using the WordPress editor to update PHP code. Thank you.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.