.htaccess file help needed

My website URL is:
watzup.epizy.com

i am trying to upload my files so i can install the sites script but it keep being deleted as its is 12kbs in size. i seen that max size is 10kbs but i have no idea how to make it smaller without it effecting the site.
Is there anyway i can get the size limit increased so this file doesnt keep dissapearing

not, you have to have a premium account :frowning:

wow ok not a problem, i guess ill have a look around for other hosts as other hosts dont seem to have such a minor issue

I’m in exactly the same position. I can live with the file size limits for content but this 10k limit on the .htaccess file is a deal breaker. I thought you’d like to know yet another potential user (and possibly not always a free user) is forced to look elsewherre for the sake of a few bytes of .htaccess - I expect you’ll see a lot of this given my need to rewrite ‘pretty’ URLs.

I’d say thanks for trying though ‘infinity’, it is actually a shame.

I’m not sure what kind of URL rewrites you have to do that requires over 10 kB of rules. By comparison, the rewire rules for the client area (which is quite a complex application) is only 443 bytes.

In my experience, there is hardly any reason why a .htaccess file has to be bigger than 10 kB. The only cases where I know people had files that big was because they did country whitelisting with .htaccess rules, which required a huge amount of allow/deny rules to whitelist all the IP ranges of all providers in the country. Which is easier and prettier to do with GeoIP lookups in PHP.

If you have a file of over 10 kB with only rewrite rules, I’m very curious to learn what your .htaccess file looks like. Would you care to elaborate?

I got an e-mail reply that I can’t see here! Anyway you asked abou my htaccess file. Here it is (slightly trimmed to fit)

RewriteEngine on

RewriteRule ^projects/$ /framework/promo.php?branch=projects2017 [NC,L]
RewriteRule ^projects$ /framework/promo.php?branch=projects2017 [NC,L]

RewriteRule ^products/$ /framework/promo.php?branch=products2017 [NC,L]
RewriteRule ^products$ /framework/promo.php?branch=products2017 [NC,L]

RewriteRule ^memes/$ /memes.php [NC,L]
RewriteRule ^memes$ /memes.php [NC,L]
RewriteRule ^memes/([0-9]+)/$ /memes.php?item=$1 [NC,L]
RewriteRule ^memes/([0-9]+)$ /memes.php?item=$1 [NC,L]

RewriteRule ^photography/(.+)/(.+)/page/0$ /framework/photo.php?gallery=$1&collection=$2&page=0&branch=photos2017&view=list [NC,L]
RewriteRule ^photography/(.+)/all$ /framework/photo.php?gallery=$1&collection=all&page=0&branch=photos2017&view=list [NC,L]
RewriteRule ^photography/(.+)/all/$ /framework/photo.php?gallery=$1&collection=all&page=0&branch=photos2017&view=list [NC,L]
RewriteRule ^photography/(.+)/(.+)/page/$ /framework/photo.php?gallery=$1&collection=$2&page=1&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/(.+)/page$ /framework/photo.php?gallery=$1&collection=$2&page=1&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/(.+)/page/([0-9]+)/$ /framework/photo.php?gallery=$1&collection=$2&page=$3&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/(.+)/page/([0-9]+)$ /framework/photo.php?gallery=$1&collection=$2&page=$3&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/(.+)/(.+)/$ /framework/photo.php?gallery=$1&collection=$2&item=$3&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/(.+)/(.+)$ /framework/photo.php?gallery=$1&collection=$2&item=$3&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/(.+)/$ /framework/photo.php?gallery=$1&collection=$2&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/(.+)$ /framework/photo.php?gallery=$1&collection=$2&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)/$ /framework/photo.php?gallery=$1&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/(.+)$ /framework/photo.php?gallery=$1&branch=photos2017&view=normal [NC,L]
RewriteRule ^photography/$ /framework/photo.php?branch=photos2017&view=normal [NC,L]
RewriteRule ^photography$ /framework/photo.php?branch=photos2017&view=normal [NC,L]

RewriteRule ^poetry/collection/(.+)/$ /framework/item.php?collection=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/collection/(.+)$ /framework/item.php?collection=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/collection/$ /framework/item.php?branch=poems2 [NC,L]
RewriteRule ^poetry/collection$ /framework/item.php?branch=poems2 [NC,L]
RewriteRule ^poetry/tag/(.+)/$ /framework/item.php?tag=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/tag/(.+)$ /framework/item.php?tag=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/tag/$ /framework/item.php?tag=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/tag$ /framework/item.php?tag=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/tag/(.+)/$ /framework/item.php?item=$1&tag=$2&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/tag/(.+)$ /framework/item.php?item=$1&tag=$2&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/tag/$ /framework/item.php?item=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/tag$ /framework/item.php?item=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/collection/(.+)/$ /framework/item.php?item=$1&collection=$2&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/collection/(.+)$ /framework/item.php?item=$1&collection=$2&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/collection/$ /framework/item.php?item=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/collection$ /framework/item.php?item=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)/$ /framework/item.php?item=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/(.+)$ /framework/item.php?item=$1&branch=poems2 [NC,L]
RewriteRule ^poetry/$ /framework/item.php?branch=poems2 [NC,L]
RewriteRule ^poetry$ /framework/item.php?branch=poems2 [NC,L]

RewriteRule ^stories/collection/(.+)/$ /framework/item.php?collection=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/collection/(.+)$ /framework/item.php?collection=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/collection/$ /framework/item.php?branch=stories2017[NC,L]
RewriteRule ^stories/collection$ /framework/item.php?branch=stories2017[NC,L]

RewriteRule ^stories/tag/(.+)/$ /framework/item.php?tag=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/tag/(.+)$ /framework/item.php?tag=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/tag/$ /framework/item.php?tag=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/tag$ /framework/item.php?tag=$1&branch=stories2017 [NC,L]

RewriteRule ^stories/(.+)/tag/(.+)/$ /framework/item.php?item=$1&tag=$2&branch=stories2017 [NC,L]
RewriteRule ^stories/(.+)/tag/(.+)$ /framework/item.php?item=$1&tag=$2&branch=stories2017 [NC,L]
RewriteRule ^stories/(.+)/tag/$ /framework/item.php?item=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/(.+)/tag$ /framework/item.php?item=$1&branch=stories2017 [NC,L]

RewriteRule ^stories/(.+)/collection/(.+)/$ /framework/item.php?item=$1&collection=$2&branch=stories2017 [NC,L]
RewriteRule ^stories/(.+)/collection/(.+)$ /framework/item.php?item=$1&collection=$2&branch=stories2017 [NC,L]
RewriteRule ^stories/(.+)/collection/$ /framework/item.php?item=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/(.+)/collection$ /framework/item.php?item=$1&branch=stories2017 [NC,L]

RewriteRule ^stories/(.+)/$ /framework/item.php?item=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/(.+)$ /framework/item.php?item=$1&branch=stories2017 [NC,L]
RewriteRule ^stories/$ /framework/item.php?branch=stories2017 [NC,L]
RewriteRule ^stories$ /framework/item.php?branch=stories2017 [NC,L]

RewriteRule ^articles/collection/(.+)/$ /framework/item.php?collection=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/collection/(.+)$ /framework/item.php?collection=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/collection/$ /framework/item.php?branch=articles2017 [NC,L]
RewriteRule ^articles/collection$ /framework/item.php?branch=articles2017 [NC,L]
RewriteRule ^articles/tag/(.+)/$ /framework/item.php?tag=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/tag/(.+)$ /framework/item.php?tag=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/tag/$ /framework/item.php?tag=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/tag$ /framework/item.php?tag=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/tag/(.+)/$ /framework/item.php?item=$1&tag=$2&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/tag/(.+)$ /framework/item.php?item=$1&tag=$2&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/tag/$ /framework/item.php?item=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/tag$ /framework/item.php?item=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/collection/(.+)/$ /framework/item.php?item=$1&collection=$2&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/collection/(.+)$ /framework/item.php?item=$1&collection=$2&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/collection/$ /framework/item.php?item=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/collection$ /framework/item.php?item=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)/$ /framework/item.php?item=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/(.+)$ /framework/item.php?item=$1&branch=articles2017 [NC,L]
RewriteRule ^articles/$ /framework/item.php?branch=articles2017 [NC,L]
RewriteRule ^articles$ /framework/item.php?branch=articles2017 [NC,L]

RewriteRule ^video/collection/(.+)/$ /framework/item.php?collection=$1&branch=video2017 [NC,L]
RewriteRule ^video/collection/(.+)$ /framework/item.php?collection=$1&branch=video2017 [NC,L]
RewriteRule ^video/collection/$ /framework/item.php?branch=video2017 [NC,L]
RewriteRule ^video/collection$ /framework/item.php?branch=video2017 [NC,L]
RewriteRule ^video/tag/(.+)/$ /framework/item.php?tag=$1&branch=video2017 [NC,L]
RewriteRule ^video/tag/(.+)$ /framework/item.php?tag=$1&branch=video2017 [NC,L]
RewriteRule ^video/tag/$ /framework/item.php?tag=$1&branch=video2017 [NC,L]
RewriteRule ^video/tag$ /framework/item.php?tag=$1&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/tag/(.+)/$ /framework/item.php?item=$1&tag=$2&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/tag/(.+)$ /framework/item.php?item=$1&tag=$2&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/tag/$ /framework/item.php?item=$1&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/tag$ /framework/item.php?item=$1&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/collection/(.+)/$ /framework/item.php?item=$1&collection=$2&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/collection/(.+)$ /framework/item.php?item=$1&collection=$2&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/collection/$ /framework/item.php?item=$1&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/collection$ /framework/item.php?item=$1&branch=video2017 [NC,L]
RewriteRule ^video/(.+)/$ /framework/item.php?item=$1&branch=video2017 [NC,L]
RewriteRule ^video/(.+)$ /framework/item.php?item=$1&branch=video2017 [NC,L]
RewriteRule ^video/$ /framework/item.php?branch=video2017 [NC,L]
RewriteRule ^video$ /framework/item.php?branch=video2017 [NC,L]

#removed most of sudio due to limits of infinityfree webhosts
RewriteRule ^audio/$ /framework/item.php?branch=audio2017 [NC,L]
RewriteRule ^audio$ /framework/item.php?branch=audio2017 [NC,L]

RewriteRule ^$ /framework/promo.php?branch=home2017 [NC,L]

Thank you for sharing, I see what you mean now.

I can see what you are trying to do with these htaccess rules, but I also think that you can achieve the same with a much smaller rule set.

The most common way to do rewrite rules is to just forward all requests to a single index.php file, and to route them from there. For example, these are the .htaccess rules used by WordPress:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

But with your software that doesn’t really seem to work because of the different entry scripts.

Nevertheless, I think it’s possible to drastically reduce the number of .htaccess rules with a few changes.

For starters, I see a lot of cases where you have a rule for both the URL with and without a trailing slash, e.g. ^projects/$ and ^projects$. By using the ? operator, you can make the expression match both URLs. So you can replace the two lines with one line saying ^projects/?$. This reduces your .htaccess file size by half without changing a single line of PHP code.

If you are willing to make some relatively minor changes to the PHP code, you could omit rewriting all the query parameters to their own GET params. So if you have a few lines of PHP which takes $_SERVER['REQUEST_URI'] and checks if the first part is stories or poetry, and then checks if the second argument is tag, collection or an ID, the entire .htaccess file could be reduced to this:

RewriteEngine On

RewriteRule ^projects/?$ /framework/promo.php [NC,L]
RewriteRule ^memes(.*)$ /memes.php [NC,L]
RewriteRule ^photography(.*)$ /framework/photo.php [NC,L]
RewriteRule ^$ /framework/promo.php?branch=home2017 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /framework/item.php [L]

Why would you do this? Keep in mind that .htaccess rules are executed for every request. So these .htaccess rules need to be checked, parsed and evaluated for every PHP script, every image and every CSS/JS request which comes in. You can imagine that processing a large number of rules for every hit is quite complex, and as such can increase server load and page load times. That’s why we set the size limit to begin with.

Whether you make any of the changes I proposed is completely up to you. But I did want to share that you really don’t need huge .htaccess files to have pretty URLs. With some smart regular expressions in your .htaccess code, and/or a little bit of extra PHP code, you can achieve the same results.

This is an absolutely brilliant response. Thanks so much. I don’t think I will host my own site at infinityfree as I suspect I serve too much traffic given the (now discovered) daily bandwidth limits BUT I have a friend who is looking to re-use my sources for their own nascent web presence. I’ll work through the above and restructure my approach to .htaccess and then I will GLADLY recommend your service to them (and in fact to others as time goes by) on the basis of just how very helpful you have been.
Kind Regards
Ant

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.