Sometimes, when you upload a file, the upload is completed but the file is deleted immediately afterwards. This is usually caused by one of the following issues:
All websites files must be uploaded to either the main
htdocs folder, or to the domain specific
htdocs folder (like
You cannot upload files to other directories on your account. If you try to create or upload files anywhere else, they will be deleted automatically.
Certain file types, like
If you would like to offer something for download or embed a video in your website, please use a specialized file sharing service or video streaming service for that instead.
Uploaded files are automatically scanned for malware. If malware is detected in a file, it’s automatically deleted to prevent damage to your website and your visitors.
The InfinityFree web servers have size limits for all files. If the file size exceeds the limit, the file is automatically deleted.
The size limits are:
- HTML and PHP files are limited 1 MB.
- .htaccess files are limited to 10 kB.
- All other files are limited to 10 MB.
Please note that this is a file size limit, not just a PHP upload limit. All files on your account are subject to this limit, regardless of how you’re trying to get this file on your account.
Depending on the contents of your PHP/HTML file, you may be able to reduce the file size in one of the following ways:
- If the HTML page contains a lot of data to be displayed to visitors, you may be able to move this data to separate text files or a MySQL or SQLite database which can be queried from PHP.
- If the file contains a lot of PHP code, you may be able to move some of this code to separate files, and use PHP
requiredirectives to combine the code in a single process. This also makes it easier to reuse code across multiple pages, and generally makes it easier to read and understand.
- If the file contains a lot of HTML code, you can also use PHP
requiredirectives to combine multiple HTML files, like headers and footers, into a single page. However, note that having a very large HTML page means it may be very slow to load for people and use a lot of bandwidth, which is bad for (mobile) users. So you may also wish to consider to restructure your website so spread the content over multiple, specific pages.
If you want to upload a large archives (.zip, .rar, .tar.gz), please see the article How to upload big files/archives for workarounds.
For text files, consider splitting the text across separate files, and either serving the files separately or joining them at request with PHP.
For media files, you may be able to choose different encoding (e.g. MP3 vs WAV audio), or apply stronger compression to reduce the file size. Alternatively, you could use a specialized photo/music/video/etc. hosting service to share the content and link to those services from your website.
A large .htaccess file can negatively impact server performance which can slow down your website and the websites of others. So using large .htaccess files should be avoided in general.
Below are a few common use cases for large .htaccess files and ways to work around them.
One common way to block bad bots is filtering and blocking access to specific User Agent information sent by the client.
Such .htaccess rules are typically of limited use and should be removed, for multiple reasons:
- User agents are freely configurable by the client, and many bad bots pretend to be popular browsers on common operating systems, which can’t be caught by such filters.
- Free hosting already comes with a security system to keep out bots, which works more effectively than a user agent filter.
So you can safely remove these lines and know that your website is already protected in more effective ways.
If you want to restrict access to your website to certain countries (either blacklisting or whitelisting certain regions), one such way is to only allow or deny access to IP addresses in certain ranges.
You can deal with this by moving the IP blacklisting/whitelisting to PHP code, from where you can also filter IP addresses.
But it should be noted that using IP ranges for country restrictions is an inherently flawed method. IP ranges are assigned to network operators, who can then use those IP addresses wherever they want, or even use them in multiple locations at the same time. It’s impossible to have a definitive list detailing which IP address ranges belong to which country.
From PHP, you can also use a GeoIP service to get more accurate location information about specific IP addresses.
And finally, from your PHP code, it’s much easier to customize what people will see if they are blocked. With a .htaccess file, they would only see a generic “403 Forbidden” page.
If you’re written your own software, you may have a large set of rewrite rules to send specific URLs to specific pages. This is an acceptable way to handle routing in your application, but may lead to very large .htaccess files as your application grows bigger.
Most frameworks and CMS handle routing from within PHP. So all page requests are redirected to single
index.php file, from where PHP code selects which code to execute for the requested URL.