0

I'm using gcloud's app engine with my index.php file in in a directory called '/public'. I set the app.yaml file's entry point to start there, so it treats that folder like the root directory in the url.

When I manually code the links on my site (href="home") everything works great (link shows as mysiteurl.com/home). When I use href="{{ urlFor('home') }}" the link shows as mysiteurl.com/public/home.

All the links work, and the site runs without error, but I don't want the /public showing up in the links or url. Is there a way to set an "entry point" (like in gcloud) for slim/twig so it treats /public as the root directory when generating links?

Update: This may actually be a gcloud issue. On localhost everything works as expected (using an .htaccess file that is ignored in .gcloudignore) but when I deploy the app the links become /public/page. Maybe app.yaml entry point is causing the issue?

Addtl Info: I'm using a standard environment and here is my app.yaml file:

runtime: php72

entrypoint: serve public/index.php

basic_scaling:
  max_instances: 1
  idle_timeout: 5m

handlers:
- url: /css
  static_dir: public/css
- url: /data
  static_dir: public/data
- url: /fonts
  static_dir: public/fonts
- url: /img
  static_dir: public/img
- url: /js
  static_dir: public/js
- url: /libs
  static_dir: public/libs
- url: /scss
  static_dir: public/scss

- url: /.*
  script: auto
  secure: always
JohnDNoone
  • 11
  • 2
  • What does your `.htaccess` looks like? – DarkBee Feb 04 '20 at 07:00
  • According to gclouds documentation, they ignore `.htaccess` files. The entry point on the `app.yaml` file is supposed to serve all scripts through `/public/index.php` – JohnDNoone Feb 04 '20 at 07:06
  • I've added the gcloud tag for you. Hope you get the answer this way – DarkBee Feb 04 '20 at 07:29
  • @DarkBee Thanks! Since this may be a gcloud-specific issue it would make sense to tag it as such! – JohnDNoone Feb 04 '20 at 07:34
  • Hi, could you specify if your are using standard or flex env? also, could you add a minimal reproducible example to your question (along with the app.yaml)? (redacting any sensitive information) . – Mayeru Feb 04 '20 at 13:03
  • @Mayeru I added my app.yaml file (removing environment variables) and mentioned using a standard environment. – JohnDNoone Feb 04 '20 at 17:20
  • The issue seems to reside on the fact that you are depending on the ".htaccess" file which is not carried on in App Engine Standard. You would need to translate the rules from the ".htaccess" on the app.yaml file with handler/urls, similar to this -> https://cloud.google.com/appengine/docs/standard/php/config/appref#example Also, there's a doc which shows a way to simulate this but keep in mind is from PHP5 -> https://cloud.google.com/appengine/docs/standard/php/config/mod_rewrite – Mayeru Feb 06 '20 at 17:06

0 Answers0