Forbidden Error 403 On Server Folder - php

I'm trying to host a new blog where I can add posts using a simple HTML form & PHP script. When I test out the form on my localhost everything works fine, but when I upload it and test it live I get:
Forbidden
You don't have permission to access /php/add-post.php on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
I know that my host allows this type of script because I'm using exactly the same thing on another blog, and my permissions are set to 0755. Does anyone know what the problem might be & how to solve it?

Add the below code in .htaccess file
<Files add-post.php>
Order Deny,Allow
Deny from all
Allow from all
</Files>
Or run command to provide permission to folder
chmod 774 /path/to/php/add-post.php

Related

Sudden forbidden access to wp-admin beacuse of .htaccess file problem

I am currently having a very sudden problem with a website. It was working fine but now when trying to access the wp-admin I get the following error.
Forbidden
You don't have permission to access this resource.Server
unable to read htaccess file, denying access to be safe
Additionally, a 403 Forbidden error was encountered while trying to
use an ErrorDocument to handle the request.
I found the .htaccess file in the bluehost login and the permissions are 664, and it seems a have another identical .htacess file in another folder, I don't know if that may be causing the problem.
The .htaccess file looks like this
<FilesMatch ".(py|exe|phtml|php|PHP|Php|PHp|pHp|pHP|phP|PhP|php5|suspected)$"> Order Allow,Deny Deny from all </FilesMatch>
Actually all of my .htaccess files have a editing date two days ago and I don't get why.

403 Forbidden - how to fix?

I'm trying to access an PHP 7.x file on a restricted webspace, but get the famous 403:
Forbidden
You don't have permission to access /path/to/file.php on this server.
After searching on StackOverflow and trying different settings, I set the CHMOD to 777, which didn't change anything.
I've no root nor apache access.
Now I'm trying to allow access via .htaccess, but no success so far:
Order Allow,Deny
Allow from all
Result: 500 - Internal Server Error.
Any idea?
Thanks in advance!

Joomla 403 Forbidden when trying to access php file

I have a Joomla site. I've created a subfolder with a landing page.
This landing page was coded in HTML + CSS. This works perfectly but now I have added a little PHP plugin to manage MailChimp subscribers. But when I try to access to the php file, the server throws the following 403 error:
Forbidden
You don't have permission to access http://www.domain.es/folder/sub-folder/server.php
I have changed the .htaccess file to allow PHP files the following way (but it doesn't work):
<FilesMatch *.php$>
Allow from all
</FilesMatch>
Any ideas?
Try renaming server.php to myfile.php and see if you still have the same problem. It might be that your Apache server configuration has a rule to block server.php because, in many instances, files that have server.php as their name are malicious.

403 Forbidden : You don't have permission to access

Forbidden
You don't have permission to access /install/step3.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Why is it showing this error when I'm trying to install a script?
Your question have 2 configuration problem.
File Permission (in Filesystem)
ErrorDocument Attribute (in Apache Webserver)
First, You can solve permission error using 'chmod' and 'chown' command.
try this:
chmod -R 777 directory (777 means allow permission for all)
chown -R [user]:[group] directory (generally, the same [user] and [group])
Second, ErrorDocument handle error can occured from invaild ErrorDocument attribute setting in .htacess or httpd.conf(or apache2.conf) file.
try this:
check your .htacess file in 'install/' directory. If you can not check this file, you can try 'ls -al' command in terminal. you have to find 'ErrorDocument' attribute, and remove or correct it.
check your apache webserver configuration file (httpd.conf or apache2.conf). If you can check 'ErrorDocument' attribute, you can try remove this attribute in file. It is temporary, so you must backup it before try suggested cases.
If you can not solve by case 1 and 2, you can try disable 'AllowOverride' attribute. Try find 'AllowOverride x' attribute and replace to 'AllowOverride None'. Because, this problem can have possiblity from .htacess file in parent directories. AllowOverride attribute can control allow or deny additional configuration in .htacess file.
You must restart apache service after try this cases. you can try 'service httpd restart' or 'service apache2 restart' command.
Good luck to your web server and you.
First thing to do is check that the index.html is written in properly. Forbidden 403 usually indicates that the server is running but that the requested resource is not being found.
Then clear your cache. Additionally check your php.ini file to configure any necessary items to get your website running.
The Web server (running the Web site) thinks that the HTTP data stream sent by the client (e.g. your Web browser or our CheckUpDown
robot) was correct, but access to the resource identified by the URL
is forbidden for some reason.
This indicates a fundamental access problem, which may be difficult to
resolve because the HTTP protocol allows the Web server to give this
response without providing any reason at all. So the 403 error is
equivalent to a blanket 'NO' by the Web server - with no further
discussion allowed.
By far the most common reason for this error is that directory
browsing is forbidden for the Web site. Most Web sites want you to
navigate using the URLs in the Web pages for that site. They do not
often allow you to browse the file directory structure of the site.
For example try the following URL (then hit the 'Back' button in your
browser to return to this page):
http://www.checkupdown.com/accounts/grpb/B1394343/
This URL should fail with a 403 error saying "Forbidden: You don't
have permission to access /accounts/grpb/B1394343/ on this server".
This is because our CheckUpDown Web site deliberately does not want
you to browse directories - you have to navigate from one specific Web
page to another using the hyperlinks in those Web pages. This is true
for most Web sites on the Internet - their Web server has "Allow
directory browsing" set OFF.
I have faced this problem. On local host it was running as I want, but when deployed (using Filezilla in my case) on the remote server, the problem occurred. with error 403 instead of 404. I think as mentioned before, It is a restricted access from the server. I only reuploaded the whole folder and every thing is perfect now.
Thanks to this community.
.htaccess
ErrorDocument 404 /index.php
ErrorDocument 403 /index.php
ErrorDocument 403.14 /index.php
ErrorDocument 500 /index.php

403 Forbidden response – what should I look for?

I have a script giving me error 403 Forbidden error, it's just a copy of another script but the difference in this is that both use another mysql class to access database.
My whole project is complete and this is last file so I don't want to do the whole work again for a single file.
Server logs shows that client denied by server configuration:
What should I look for?
I have tried the following:
Permissions are 644
New file with just simple echo gives 403 too
Changed name of folder
However, index.php works perfectly.
Check the permissions and also ownership of the file. Generally, 403 means that the web server doesn't have the rights to read the file and therefore can't continue the request. The permissions may be set correctly, however the file might be owned by another account on the server - an account that isn't part of the same group as the account which is running the server.
For instance, I believe* Apache is ran by default under the httpd user account, which is part of the httpd group. However, the FTP user you're logging in as (for instance ftpuser) might not be part of the httpd group. So, in copying the file you've created it under a different user account and Apache won't get execute access with 644.
* it's been a while since I've used apache, but it's similar under nginx.
This isssue occurs if you have had denied for all in .htaccess file. Changing that resolves the issue.
I had the same problem. The .htaccess file in my root folder has this code:
<Files ~ "\.(php|php5|py|jsp|cgi|sh)$">
Require all denied
</Files>
But there was a folder /example where I needed to call php files, so I created a .htaccess file in that specific folder with this content:
<Files ~ "\.(php)$">
Require all granted
</Files>
Note: I am running Apache 2.4

Categories