sitemap.php permission

Hi,

I have followed the install instructions for the simple sitemaps plugin. When I navigate to mydomain.com/sitemap.xml in my browser I get the following error:

Forbidden

You don’t have permission to access /wp-content/sitemap.php on this server.

Possible causes of this error include:

The request was forbidden by rules in the .htaccess file.

The directory you requested does not have an index.html or index.php file.

The permissions on the file or directory are incorrect.

For details about why the request was forbidden, see the Apache error log at:

/srv/users/SYSUSER/log/APPNAME/APPNAME_apache.error.log

I have set the file permissions to 777, and checked that the indax.php file is in the directory.

What can I do to fix this?

  • Kasia Swiderska
    • Support nomad

    Hello mcneela86,

    Can you check if you have additional htaccess file in wp-content directory from Defender? I can see that you are using it, so it might be that one of the hardening recommendation is blocking that file.

    If you find that htaccess inside wp-content directory, add there in that file this code

    <Files sitemap.php>
    Allow from all
    </Files>

    that should exclude file and site maps should start working.

    kind regards,

    Kasia

  • mcneela86
    • WPMU DEV Initiate

    Hi Kasia,

    I have located the .htaccess file inside wp-content, I added the code you mentioned, it not looks like this:

    ## WP Defender – Prevent PHP Execution ##

    <Files *.php>

    Order allow,deny

    Deny from all

    </Files>

    Files sitemap.php>

    Allow from all

    </Files>

    ## WP Defender – End ##

    I get a different error:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    The most common causes of this problem are errors in the app’s .htaccess file or incorrect file or directory permissions preventing the web server from reading the .htaccess file.

    More information about this error is available in the app’s Apache error log at:

    /srv/users/SYSUSER/log/APPNAME/APPNAME_apache.error.log

  • Dimitris
    • Support Star

    Hey there mcneela86,

    hope you’re doing good and don’t mind chiming in! :slight_smile:

    It seems that there was an error in your code, a missing opening <Files> tag.

    Could you please use the following snippet instead and check how that goes?

    ## WP Defender - Prevent PHP Execution ##
    <Files *.php>
    Order allow,deny
    Deny from all
    </Files>
    ## WP Defender - End ##
    <Files sitemap.php>
    Allow from all
    </Files>

    Warm regards,

    Dimitris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.