# NGINX / Apache2 Hybrid Server - RewriteRule ^content/(.\*) index.php \[L\] Not working

**URL:** <https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131>\
**Category:** Questions\
**Created:** [November 29, 2023, 10:48am UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131 "2023-11-29T10:48:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mactedder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mactedder/32/10802_2.png) [@mactedder](https://forum.getkirby.com/u/mactedder)\
**Post date:** [November 29, 2023, 10:48am UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/1 "2023-11-29T10:48:28Z")

</div>

I am just launching a Kirby site on our Runcloud hosting - The hosting is setup on a NGINX/Apache2 Hybrid stack (Allows .htaccess to be used).

My Kirby panel warns me my content folder is exposed even though I have all the default Kirby .htaccess settings including `RewriteRule ^content/(.*) index.php [L]`

Any ideas why this would not be working?

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [November 29, 2023, 1:26pm UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/2 "2023-11-29T13:26:40Z")

</div>

Its because everythings in the web root, ie the `public` or `www` or whatever your host has called it. If your host allows you to you, you can place those folders outside of the public area which increases security.

See here:

> **[Configuring Kirby](https://getkirby.com/docs/guide/configuration#custom-folder-setup__public-folder-setup)**
>
> Almost every aspect of Kirby can be controlled and configured to do exactly what you need it to do.

---

<div class="post-metadata">

**Author:** ![mactedder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mactedder/32/10802_2.png) [@mactedder](https://forum.getkirby.com/u/mactedder)\
**Post date:** [November 29, 2023, 1:32pm UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/3 "2023-11-29T13:32:30Z")

</div>

> [@mactedder](#):
>
> RewriteRule ^content/(.\*) index.php

I thought the above code should still work though?

---

<div class="post-metadata">

**Author:** ![mactedder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mactedder/32/10802_2.png) [@mactedder](https://forum.getkirby.com/u/mactedder)\
**Post date:** [December 2, 2023, 10:53am UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/4 "2023-12-02T10:53:45Z")

</div>

Still looking for a solution to this one. Anyone?

---

<div class="post-metadata">

**Author:** ![Adspectus](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/adspectus/32/189_2.png) [@Adspectus](https://forum.getkirby.com/u/Adspectus)\
**Post date:** [December 2, 2023, 11:34am UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/5 "2023-12-02T11:34:34Z")

</div>

> [@mactedder](#):
>
> My Kirby panel warns me my content folder is exposed

How does this look like and where does it come from? I have Apache with a standard Kirby setup and never see such warning. Knowing the source where this warning is triggered might help finding the reason.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 2, 2023, 11:45am UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/6 "2023-12-02T11:45:46Z")

</div>

Kirby checks the following urls to determine if any of the folders is exposed.

- yourdomain/content/site.txt
- yourdomain/kirby/composer.json
- yourdomain/.git/config
- yourdomain/site/blueprints/site.yml

Please check what responses you get for them. Maybe you have a redirect in place somewhere that causes this, returning a 302 instead of a 404.

---

<div class="post-metadata">

**Author:** ![mactedder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mactedder/32/10802_2.png) [@mactedder](https://forum.getkirby.com/u/mactedder)\
**Post date:** [December 3, 2023, 3:54pm UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/7 "2023-12-03T15:54:19Z")

</div>

I can see the site.txt file when I check.

I have the default Kirby .htaccess file and have not changed any settings.

I am not sure why the is is viewable still, and giving me the warning in the panel settings.

---

<div class="post-metadata">

**Author:** ![Adspectus](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/adspectus/32/189_2.png) [@Adspectus](https://forum.getkirby.com/u/Adspectus)\
**Post date:** [December 3, 2023, 4:51pm UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/8 "2023-12-03T16:51:05Z")

</div>

> [@mactedder](#):
>
> NGINX/Apache2 Hybrid stack

Maybe you need to dive deeper into the settings of your provider. Citing their docs:

> By using this stack, your static files (eg: css,js,images,fonts) will be served by NGINX. If it is PHP, NGINX will pass it to Apache2 and the request will be passed to PHP-FPM.

For me, this means that requests for static files will not be served by Apache and thus no evaluation of its `.htaccess` rules. The rules therein will only be taken into account if `.php` files are requested. However, the sense of Kirby’s `.htaccess` file is to redirect all requests pertaining to any file in the `site`, `kirby` or `content` folder to the main `index.php` which serves as a dispatcher.

---

<div class="post-metadata">

**Author:** ![mactedder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mactedder/32/10802_2.png) [@mactedder](https://forum.getkirby.com/u/mactedder)\
**Post date:** [December 3, 2023, 7:01pm UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/9 "2023-12-03T19:01:13Z")

</div>

Thanks for the reply. I have just had the same response from Runcloud support.

“it’s because you are on a Hybrid stack in which the static files like TXT, HTML etc are handled by the Nginx and not by the Apache.”

---

<div class="post-metadata">

**Author:** ![mactedder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mactedder/32/10802_2.png) [@mactedder](https://forum.getkirby.com/u/mactedder)\
**Post date:** [December 3, 2023, 8:00pm UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/10 "2023-12-03T20:00:18Z")

</div>

I have added a NGINX Config file as follows which seems to have done the trick, but doesnt target the ‘Content’ folder specifically.:

```auto
location ~ \.txt$ {
        # Deny access to all .txt files
        deny all;
        return 404;
        }

```

Is this okay - Does anyone know enough about NGINX for how to be more specific?

---

<div class="post-metadata">

**Author:** ![assbach](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/assbach/32/13832_2.png) [@assbach](https://forum.getkirby.com/u/assbach)\
**Post date:** [May 15, 2024, 9:20am UTC](https://forum.getkirby.com/t/nginx-apache2-hybrid-server-rewriterule-content-index-php-l-not-working/30131/11 "2024-05-15T09:20:07Z")

</div>

I think i’m having the same issue on one of our servers. The htaccess Rewrite seem to be ignored. Everything works fine on a development server but not on the production system. The difference i found is some setting in PLESK which seems to be for performance reasons only. When i switch it on in the DEV-server i get the same warning in the panel (content folder not safe).

![SCR-20240514-iqzl](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/7/756f1745da6ddeefc8c20eefa447c0a6a8dec112.png)  
i’m talking about the third checkbox (static files handled by nginx)

I don’t have access to the nginx config myself, but asked the hosting colleagues to see [this guide](https://getkirby.com/docs/cookbook/development-deployment/nginx#boilerplate-config) and try out some things.

We need to run kirby in a subfolder /kirby/ for the time being (this will later be the docroot), so i guess there need to be made some adjustments to the nginx config example but i am not familiar with the nginx syntax. Does someone have any hints? Atm all tests result in a “not found” error when trying to access /kirby/

My next idea is to try and switch off the checkbox on the production server and see what difference it makes to the performance, if any. Have to find a good way to test that. Any hints appreciated.

@mactedder did you find a way to solve it?

Thank you!
