Subpages not working on local server after migration

Hi,
we have a company website developed with Kirby 2 running perfectly since years.

We have also a local test installation of that site. The server specification is
Windows Server 2016, Apache 2.4.33, PHP 7.4.7
Has been running perfectly until last week. I moved the installation folder to another location on same server, because this server is going to be our fileserver in future. I changed the path in apache httpd.conf to the new location.

Problem
I can see the start page, but no subpages.

What I already tried
I checked the troubleshooting advices and have been reading every forum post regarding “subpages”, “mod_rewrite”, “.htaccess”, “rewrite base” etc. etc.
So I moved the installation back to a similar folder like before (I had deleted the original one). No success.
I took the original Kirby 2.5.12 starterkit with original .htaccess
No success

Detailed Information
Kirby starterkit 2.5.12 now located in D:\Test\kirby-fresh-starterkit
httpd.conf entry is:

Alias /kirby-starterkit "D:\Test\kirby-fresh-starterkit"

<Directory "D:\Test\kirby-fresh-starterkit">
AllowOverride All
Require ip 192.168.115 

# Für PHP 
Options +ExecCGI
</Directory>

Server name is apollo1, so when I go to http://apollo1/kirby-starterkit/
I see the startpage and even those 3 images below the project A to project C blocks.

Apache log says

192.168.115.23 - - [15/Jun/2020:07:38:26 +0200] "GET /kirby-starterkit/ HTTP/1.1" 200 4099
192.168.115.23 - - [15/Jun/2020:07:38:29 +0200] "GET /kirby-starterkit/assets/css/index.css    HTTP/1.1" 200 17894
192.168.115.23 - - [15/Jun/2020:07:38:29 +0200] "GET /kirby-starterkit/thumbs/projects/project-b/room-600x600.jpg HTTP/1.1" 200 62337
192.168.115.23 - - [15/Jun/2020:07:38:29 +0200] "GET /kirby-starterkit/thumbs/projects/project-a/creative-tools-600x600.jpg HTTP/1.1" 200 88271
192.168.115.23 - - [15/Jun/2020:07:38:29 +0200] "GET /kirby-starterkit/thumbs/projects/project-c/camera-600x600.jpg HTTP/1.1" 200 83599

etc. so all the stuff from subdirectories is 200 OK

When I go to http://apollo1/kirby-starterkit/projects/project-a I get in Firefox:

Not Found
The requested URL /Test/kirby-fresh-starterkit/index.php was not found on this server.

and in apache log

192.168.115.23 - - [15/Jun/2020:08:00:19 +0200] "GET /kirby-starterkit/projects/project-a HTTP/1.1" 404 235

however,

http://apollo1/kirby-starterkit/thumbs/projects/project-a/creative-tools-600x600.jpg

is displayed with no error.

Assumption
Must be an issue with directory rights or apache configuration. mod_rewrite is working.

Isn’t it so that the following lines from .htaccess

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

render all subpage accesses back down to the main index.php?

Browser keeps telling me

The requested URL /Test/kirby-fresh-starterkit/index.php was not found on this server.

for any subpage, but it is definitely present.

Apache httpd.exe service runs under SYSTEM account;
in the install folder D:\Test\kirby-fresh-starterkit the user SYSTEM has full read/write access.

Any ideas?

It seems to be a rewrite issue, because index.php should not appear in the URL if rewriting is enabled. On a side note, maybe not related, PHP 7.4 support was only added with Kirby 2.5.13, so you would have to update.

Please also note that security support for Kirby 2 will end Dec 31, 2020.

I think you need 2.5.13 for PHP 7.4 support: Release 2.5.13 · getkirby-v2/kirby · GitHub

Yes, I am aware that we should go to Kirby 3. It’s an issue of time… the docs talking of “nearly everything” must change on a Kirby 2 > Kirby 3 migration. I also didn’t find really helpful information (pricing) about upgrading our license.

I have also Kirby 3 starterkit installed in D:\Test\kirby-starterkit-master
The corresponding httpd.conf entry is

Alias /kirby-master "D:\Test\kirby-starterkit-master"
<Directory "D:\Test\kirby-starterkit-master">
AllowOverride All
Require ip 192.168.115 

# Für PHP 
Options +ExecCGI
</Directory>

and when I go to http://apollo1/kirby-master/

I see the startpage but no images, only black boxes.

Apache log says

"GET /kirby-master/ HTTP/1.1" 200 5346
"GET /kirby-master/media/pages/photography/trees/3506294441-1591947940/monster-trees-in-the-fog-1024x1024.jpg HTTP/1.1" 404 236
"GET /kirby-master/media/pages/photography/sky/3495650138-1591947940/dark-forest-1024x1024.jpg HTTP/1.1" 404 236
"GET /kirby-master/media/pages/photography/mountains/1173080142-1591947941/probably-photoshopped-1024x1024.jpg HTTP/1.1" 404 236
"GET /kirby-master/media/pages/photography/ocean/3567208724-1591947940/island-from-above-1024x1024.jpg HTTP/1.1" 404 236
"GET /kirby-master/media/pages/photography/waterfall/2577458037-1591947941/the-fall-is-lava-1024x1024.jpg HTTP/1.1" 404 236
"GET /kirby-master/media/pages/photography/desert/357164395-1591947941/indiana-jones-1024x1024.jpg HTTP/1.1" 404 236
"GET /kirby-master/assets/css/index.css HTTP/1.1" 200 2508

Note the 200 OK for the index.php and the css file, but 404 for the image stuff.

Going to http://apollo1/kirby-master/photography/trees results again in

The requested URL /Test/kirby-starterkit-master/index.php was not found on this server.

in Firefox and

"GET /kirby-master/photography/trees HTTP/1.1" 404 236

in Apache log.

@texnixe I feel it it is a httpd.conf issue; unfortunately I have no backup of the working version.
I never had to touch

# RewriteBase /

for the local installations. If I uncomment this line, it shows me content from C:\Apache24\htdocs (we have some intranet stuff there).

Hi,

I agree with @texnixe here that your problem is most probably a server misconfiguration or a redirect gone wrong. I don’t have an answer for that unfortunately.

What I noticed is you use PHP 7.4, which is not supported in the kirby version you use (which might or might not be related to your issues). There are 2 possibilities here:

  • downgrade server php version to meet kirby 2.5.12 requirements
  • upgrade kirby 2.5.12 to 2.5.13 (nobody talking about a major version upgrade to Kirby 3 here)

Success!

Ok, switched back to PHP 7.2.7 that worked before.
No change, either in Kirby 2 or Kirby 3 starterkit.

PS. I have now Kirby 2.5.12, Kirby 2.5.13, Kirby 3 and my own website installed parallel. None of them working. Error is always “index.php not found”, but only for subpages.

If it was running until last week, then you obviously made changes to your configuration that result in this failure.

  • Make sure that rewriting is really enabled
  • Make sure the .htaccess is picked up (if you add some rubbish, that should result in an error)
  • Try setting the RewriteBase

@texnixe We are coming closer.
.htaccess is picked, also for subpages. I made the rubbish test.

But: index.php is only picked for the startpage. I enabled Apache debug logging by the “LogLevel debug” switch in httpd.conf

For any subpage, I get now (in Apache error.log)

File does not exist: C:/Apache24/htdocs/Test/kirby-starterkit2513/index.php

This is apache default directory, while my installation is in:

D:\Test\kirby-starterkit2513

Something must be wrong with my Directory directives in the httpd.conf

Could you post your complete httpd.conf or make it available somehow?

httpd.conf

Thanks, I will have a look into it.

Meanwhile, you could enable rewrite logging by using

Loglevel info rewrite:trace1

which raises the Loglevel to trace1 for the rewrite module only (while lowering it to info for the rest).

The rewrite module is logging its actions only if you raise the Loglevel higher than debug (i.e. "trace1), but it would be sufficient to raise it for the rewrite module only. You can go until trace8. See this part of the Apache2 Docs about rewriting. You will find the rewrite log entries by its prefix [rewrite in the log file.

Thank you @Adspectus, thats a great way. Now I have tons of lines in my logfile, proving that rewrite is running fine.

When I go to the projects link in the 2…5.13 starterkit, I see the following:

pass through D:/Test/kirby-starterkit2513/assets/fonts/montserrat-700.woff, referer: http://apollo1/kirby-starterkit2513/assets/css/index.css
strip per-dir prefix: D:/Test/kirby-starterkit2513/projects -> projects, referer: http://apollo1/kirby-starterkit2513/
applying pattern '^content/(.*)\\.(txt|md|mdown)$' to uri 'projects', referer: http://apollo1/kirby-starterkit2513/
strip per-dir prefix: D:/Test/kirby-starterkit2513/projects -> projects, referer: http://apollo1/kirby-starterkit2513/
applying pattern '^site/(.*)' to uri 'projects', referer: http://apollo1/kirby-starterkit2513/
strip per-dir prefix: D:/Test/kirby-starterkit2513/projects -> projects, referer: http://apollo1/kirby-starterkit2513/
applying pattern '^(kirby|panel\\/app|panel\\/tests)/(.*)' to uri 'projects', referer: http://apollo1/kirby-starterkit2513/
strip per-dir prefix: D:/Test/kirby-starterkit2513/projects -> projects, referer: http://apollo1/kirby-starterkit2513/
applying pattern '^panel/(.*)' to uri 'projects', referer: http://apollo1/kirby-starterkit2513/
strip per-dir prefix: D:/Test/kirby-starterkit2513/projects -> projects, referer: http://apollo1/kirby-starterkit2513/
applying pattern '^(.*)' to uri 'projects', referer: http://apollo1/kirby-starterkit2513/
rewrite 'projects' -> 'index.php', referer: http://apollo1/kirby-starterkit2513/
add per-dir prefix: index.php -> D:/Test/kirby-starterkit2513/index.php, referer: http://apollo1/kirby-starterkit2513/
trying to replace context docroot D:\\Test\\kirby-starterkit2513 with context prefix /kirby-starterkit2513, referer: http://apollo1/kirby-starterkit2513/
internal redirect with D:/Test/kirby-starterkit2513/index.php [INTERNAL REDIRECT], referer: http://apollo1/kirby-starterkit2513/
AH00128: File does not exist: C:/Apache24/htdocs/Test/kirby-starterkit2513/index.php, referer: http://apollo1/kirby-starterkit2513/

The third-last line “trying to replace context docroot” looks suspicioius. I dont’ have such line accessing the startpage.

Here we suddenly end up in C:/…

I have not tested it but I would suggest to change two things:

  1. Use always slashes instead of backslashes in your file paths even if you are on windows

  2. Use the RewriteBase in all your sites .htaccess files (where applicable) to match your Alias, i.e. for the starterkit2513, use

    RewriteBase "/kirby-starterkit2513/"

Thank you @Adspectus, this is the point.

I replaced all backslashes by slashes in the Alias directives, and in the <Directory> directives, although it is not mandatory here. All my test installations working now.

Maybe this could be an issue for the Kirby troubleshooting / broken subpages section in the docs. I know there are many webservers supported by kirby, but in case of Apache I think this is an important hint.

I am pleased to hear that!

In fact, the RewriteBase directive should not be necessary because the rewrite engine is supposed to recognize aliased directories. However it seems that the rewrite engine can not find the correct base when using Alias with backslashes instead of slashes.

I tested also the rewrite directive, but it does not accept absolute paths on Windows e.g. D:\Test…
It supports only relative paths, and this means always relative to the Apache base “htdocs” path.

Yes, the RewriteBase directive needs an URL-path, thats why it should contain the first parameter of the Alias directive, not the second (in case it is needed at all).

See also: http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewritebase