PHP Upload files showing 403 server error - php

Getting this weird error on the server after trying to upload images with size greater than 20k. Images below that size will be uploaded successfully.
What is the problem?
by the way, the configuration in the php.ini is
upload_max_filesize = 96M
post_max_size = 96M
I am using PHP 5.6
Can you help me please ?

There can be several causes for your problem. Please check all points listed here:
The 403 Forbidden error is an HTTP status code which means that
accessing the page or resource you were trying to reach is absolutely
forbidden for some reason.
There are three common causes for this error. Here they are listed from most likely to least likely.
Empty httpdocs directory
Make sure that your website content has been uploaded to the correct directory on your server. Remember to replace example.com with your own domain name.
DV server: /var/www/vhosts/dv-example.com/httpdocs/
When you connect with your FTP user, you just need to navigate into the httpdocs directory.
If this folder does not exist, feel free to create it.
No index page
The home page for your website must be called index.php or index.html.
To resolve this error, upload an index page to your httpdocs directory.
If you already have a home page called something else - home.html for example - you have a couple of options:
Rename your home page to index.html or index.php.
Set up a redirect on the index page to your real home page. See How do I redirect my site using a .htaccess file? for details.
Set a different default home page in your .htaccess file. Javascript Kit has a good example.
If you don't want a single page to display, but instead want to show a list of files in that directory, see Making directories browsable, solving 403 errors.
Permissions and ownership errors
A 403 Forbidden error can also be caused by incorrect ownership or permissions on your web content files and folders.
source: https://mediatemple.net/community/products/dv/204644980/why-am-i-seeing-a-403-forbidden-error-message
I think your problem is the third point. You don't have permissions for an upload.

Related

How to fix "403 forbidden" redirect issue happens while adding shopping cart price rule condition in magento

My task is to add new shopping cart price rule in magento admin section. I have added rule information, then I need to add conditions for that rule .When I change the condition select box option, it's redirected to dashboard.
In the chrome console it shows 403 forbidden error in the ajax url.
Somebody told me to disable mod_security. I have written the below code in .htaceess file, but still the problem continues.
.htacesss :
SecFilterEngine Off
SecFilterScanPOST Off
I am using Magento version. 1.9.3.8
How to fix this please help me.
Fixed the Ajax 403 forbidden redirect issue in magento
Modified a single line in rule.js file. (path : /var/www/vhosts/site.com/htdocsnew/js/mage/adminhtml/rule.js)
Old
{form_key: FORM_KEY, type:new_type.replace('/','-'), id: new_id }
New
{form_key: FORM_KEY, type:new_type.replace('/','-'), id:"'"+new_id+"'" }
-Check file permissions
First, you need to check the file permissions that each of your files has set. If a file or folder is set to “777” which is “world” writable for security reasons the 403 error will be displayed to protect your website from hacks. Folders should have the permissions set to “750” or “755” and files should be set to “644”.
If you have SSH Access, you can resolve this easily. Make sure you’re in the root directory of your Magento installation, and then execute the commands.
If this will not work then you can check 'promo_catalog/newConditionHtml" is overriden anywhere in your code, local.
Also,
Check “No Index” in .htaccess file
Once you have verified that all the permissions are correct but the issue still persists, you will need to check your .htaccess file. Keep in mind that you can have multiple .htaccess files in your account, so you may need to search / modify .htaccess files other than public_html/.htaccess. For example, if you have an addon domain located at public_html/addon_domain, you’ll need to check any .htaccess files within that folder as well. If one of the lines in the actual file says “Options All -Indexes” then simply remove “-Indexes” and save the file.

Configuring php/MVC on server

I have a created a project in HTML/PHP and I am trying to upload everything to the server. I am not that familiar with servers other than the fact that your first page must be an index.php/htm file and that everything goes in the public_html folder. I am using MVC(codeigniter) so adding it to the server doesn't seem so straightforward. I have attached an image of my directories, the first file when viewed locally is the controller class which is home.php inside /application/controllers. If I just drag everything to the server as is, then I receive a 500 Internal Server Error. Can anyone help me fix this please?
The problem with a 500 internal server error is that's it's a generic message.
Try checking:
File / folder permission (No files or folders should be set to 777, 755 should be the maximum permissions setting.)
If you're using short tags: short_open_tag=On in php.ini
Incorrect syntax in .htaccess file (Try removing - test - recreate)
check error.log for more detailed information.
Hope any of this helps, I'll keep an eye on this topic.

PHP: Redirect 404 errors below specific folder

I am working on a already existing intranet. I have build an application and would like to take care of the 404 errors.
The problem I have is that this error management should only have effects on the pages located below the folder I'm working on.
Explications:
My file explorer looks like this:
root
aFolder
anotherFolder
RootOfMyApplication
myPages
I want to redirect all 404 errors below RootOfMyApplication to a specific page using PHP.
For example, browsing to "..../anotherFolder/RootOfMyApplication/notExist.php " should redirect me to my custom page, but browsing to "..../anotherFolder/notExist.php " should'nt.
If possible, I would like to make it so that directory browsing follow the same rule: if the url links to a folder and is below RootOfMyApplication, I redirect to the page.
The problem comes from the fact that I don't manage the root directory, and if possible want to have no impact on navigation outside my folder.
EDIT
What I want to do is the same as a .htaccess file: when an error is thrown, I want to take care of it myself, with PHP. My question is : "Can I do it, and if yes, how do I do it?". I don't want to use configuration files.
"It's not possible" will be accepted as an answer if there is a good explanation.
The Error Handling of files which are not found is a job of the Webserver (in your case Apache).
PHP can't help you because you always have to request one file which is then executed by PHP.
If you are going to request a file which doesn't exist, it can't be executed and the Webserver has do deal with the error. (PHP won't be started.)
But maybe there is a workaround:
If you use URL-Rewriting on your server/ application, there could be a way, but we would need some more Information/ code.
Can't you create an .htaccess in your root directory and change the error documents for your folder?
Talk to the admin and tell him he should change the error documents for your folder in httpd.conf.
(2./ 3. Maybe not an allowed solution for you, because you don't want do use configurations files.)

Plesk : Subdomains can't render a PHP file

I created a subdomain in plesk and tried to upload an index.html with some text on it, It renders well.
However, when I tries to upload an index.php with a basic text on it, it shows
Forbidden
You do not have permission to access this document.
The same error that shows when my subdomain folder is empty. At the same time it downloads a file which contains my index.php code.
Anyone have some idea about this? thank you in advance

Unexpected Rewrite

On localhost, in one of my folders, files are accessible like http://localhost/folder/map instead of http://localhost/folder/map.php. It's probably because of something wrong with Apache's configuration but I'm stuck here and nothing comes to my mind.
If you have a file called index.php or index.html in your http://localhost/folder/map folder, Apache will run that file when you just enter the directory name as a browser url.
This is what makes http://localhost run a page rather than just showing you a directory listing, or show a blank page.
This is probably the reason that you see a valid page when just keying in the http://localhost/folder/map url.

Categories