I have my kirby website in a subfolder and already changed the Rewritebase in my htaccess, but the images are not being loaded on my site.
When I turn on the RewriteBase, the entire site breaks and it says Error 403, Forbidden. As soon as I turn off RewriteBase, the site works but images cannot load.
My domain is redirecting to /html and I also tried to set RewriteBase to /sites/new and /new
Is there anything I am doing wrong?
.htaccess:
AddHandler x-httpd-php8.0 .php
# Kirby .htaccess
# revision 2020-06-15
# rewrite rules
<IfModule mod_rewrite.c>
# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on
# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder;
# otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite,
# set the RewriteBase to:
#
RewriteBase /html/sites/new
# In some environments it's necessary to
# set the RewriteBase to:
#
# RewriteBase /
# block files and folders beginning with a dot, such as .git
# except for the .well-known folder, which is used for Let's Encrypt and security.txt
RewriteRule (^|/)\.(?!well-known\/) index.php [L]
# block all files in the content folder from being accessed directly
RewriteRule ^content/(.*) index.php [L]
# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]
# block direct access to Kirby and the Panel sources
RewriteRule ^kirby/(.*) index.php [L]
# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
# pass the Authorization header to PHP
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# compress text file responses
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
I deleted the media folder, but it keeps creating emtpy folders inside its new, self created media folder. But it has successfully created every project folder and each page folder inside /media.
Kirby copies media files from the content folder into the media folder and also creates thumbs for images if you call the thumb/crop/resize etc. methods.
For thumbs, Kirby creates json job files first which are then created on the fly when the URL to a thumb is called.
When the Panel and subpages of your installation work (is that the case), then we don’t have a problem with rewriting and won’t have to look into this, but rather look into why files are not generated.
Yes, the domain is directing to /html and the kirby folders are in /html/sites/new.
When I set a subdomain to this directory, it is the exact same problem
So, now I tried to set the php version of the entire server to 8.0. I deleted the first line in my .htaccess and tried to set RewriteEngine Off and On with any of those combinations:
But no difference, the website is always displaying Error 403, Forbidden and as soon as RewriteEngine is Off, it shows the entire site but cannot find the images. It creates folders in /media which only contain a .jobs folder but no images.
But what I also noticed: it finds every caption of the images. The caption is a field inside my default image.yml blueprint. So it finds the file somehow, but cannot find the image?! @texnixe is this information helpful?
This was also the case before updating php.
In general, in many cases you don’t have to set the rewrite base at all. But if you had to set it, I think you need to set it in relation to where your domain is pointing to. So if the domain points to /html, the subfolder would be /sites/new/. etc.
Given that you said you also tried to set a subdomain to this directory, I think the issue is somewhere else. If the Panel and subpages don’t work, then likely rewriting is not enabled.
If you point a subdomain to the folder with the kirby project, what is the result? Does the homepage work? But subpages and the panel and images don’t?
when I point a subdomain to the kirby folder and turn RewriteBase off, the homepage works as fine as without the subdomain. The images are not being loaded and when I try to open the panel, the page calls “Not found”. As the page has no subpages, I cannot test, if they work.
It totally makes sense, that it would be only “/sites/new/” and I tried all combinations, but it all results in 403, forbidden.
Thanks, mod_rewrite was indeed turned off in my server properties and I turned it on. When I go to the phpinfo file, I get this table:
(There is no section called “Loaded modules”, the table below has the headline “standard” and something with “url_rewrite” in some of the last lines)
Hm, I don’t see anything similar to this. Also there is nothing when I search on the page for " e.g. “mod”.
Do I have to add something to my phpinfo.php?