1

Have a working hardcoded PHP site on a Cpanel host, am migrating (slowly cause I am a sysadmin not a coder) to Google App Engine.

Have front page and root level pages working, but pages in subdirectories not working.

GAE PHP 7.2 wants all requests to come in through a front controller which I have created, and attempted to configure site pages in, root level pages (not in subdirectories) are returned correctly, pages in subdirectories are not.

I have tried all combinations of leading slashes, not leading etc.

I suspect I need to allow the parse url function to handle slashes but am guessing a bit.

Any tips?

my-front-controller.php

<?php

switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
    case '/':
        require 'index.php';
        break;

    case '/contact-us':
        require 'contact-us.php'; 
        break;
#above case works - it is at root level#

#all below do not work#

    case 'a-page/in-a-subdirectory':
        require '/a-page/in-a-subdirectory.php';
        break;

    case '/why-choose-this-page/in-this-subdirectory':
        require '/why-choose-this-page/in-this-subdirectory.php';
        break;                
    default:
        http_response_code(404);
        exit('Not Found');

}

?>

Matt
  • 11
  • 1
  • Does [this post](https://stackoverflow.com/questions/28159977/how-to-handle-subdirectories-in-a-front-controller-pattern) help you at all? – sllopis Mar 09 '20 at 16:46

0 Answers0