# .htaccess file help needed

**URL:** https://forum.infinityfree.com/t/htaccess-file-help-needed/12915
**Category:** Hosting Support
**Created:** [February 24, 2019, 6:03pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915 "2019-02-24T18:03:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![anon38142267](https://forum.infinityfree.com/letter_avatar/anon38142267/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon38142267](https://forum.infinityfree.com/u/anon38142267)
#### Post date: [February 24, 2019, 6:03pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/1 "2019-02-24T18:03:16Z")

</div>

**My website URL is:**  
[watzup.epizy.com](http://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

---

<div class="post-metadata">

### Author: ![anon75539938](https://forum.infinityfree.com/letter_avatar/anon75539938/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon75539938](https://forum.infinityfree.com/u/anon75539938)
#### Post date: [February 24, 2019, 10:49pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/2 "2019-02-24T22:49:57Z")

</div>

not, you have to have a premium account ☹

---

<div class="post-metadata">

### Author: ![anon38142267](https://forum.infinityfree.com/letter_avatar/anon38142267/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon38142267](https://forum.infinityfree.com/u/anon38142267)
#### Post date: [February 25, 2019, 4:24am UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/3 "2019-02-25T04:24:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![anon37362240](https://forum.infinityfree.com/letter_avatar/anon37362240/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon37362240](https://forum.infinityfree.com/u/anon37362240)
#### Post date: [March 25, 2019, 9:32pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/4 "2019-03-25T21:32:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)
#### Post date: [March 26, 2019, 7:20pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/5 "2019-03-26T19:20:51Z")

</div>

> [@anon37362240](#):
>
> I expect you’ll see a lot of this given my need to rewrite ‘pretty’ URLs.

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?

---

<div class="post-metadata">

### Author: ![anon37362240](https://forum.infinityfree.com/letter_avatar/anon37362240/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon37362240](https://forum.infinityfree.com/u/anon37362240)
#### Post date: [March 26, 2019, 8:58pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/6 "2019-03-26T20:58:59Z")

</div>

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]

---

<div class="post-metadata">

### Author: ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)
#### Post date: [March 26, 2019, 10:41pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/7 "2019-03-26T22:41:33Z")

</div>

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:

```auto
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:

```auto
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.

---

<div class="post-metadata">

### Author: ![anon37362240](https://forum.infinityfree.com/letter_avatar/anon37362240/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon37362240](https://forum.infinityfree.com/u/anon37362240)
#### Post date: [March 30, 2019, 2:51pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/8 "2019-03-30T14:51:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)
#### Post date: [April 29, 2019, 2:54pm UTC](https://forum.infinityfree.com/t/htaccess-file-help-needed/12915/9 "2019-04-29T14:54:44Z")

</div>

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