New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access /path/to/public got 404 page #51

Closed
samsonasik opened this Issue Dec 19, 2015 · 9 comments

Comments

Projects
None yet
4 participants
@samsonasik

samsonasik commented Dec 19, 2015

While there is .htaccess, I am thinking we can do direct call /path/to/expressive/public in browser, but it got 404 page. Is it a .htacces config issue ?

@samsonasik

This comment has been minimized.

Show comment
Hide comment
@samsonasik

samsonasik Dec 19, 2015

this maybe on Zend\Expressive\Router path with adding leading directory accessed before "/" ?

samsonasik commented Dec 19, 2015

this maybe on Zend\Expressive\Router path with adding leading directory accessed before "/" ?

@mtymek

This comment has been minimized.

Show comment
Hide comment
@mtymek

mtymek Dec 19, 2015

This happens because Expressive has no support for "base path" - it puts whole "/path/to/expressive/public" into your router, leading to 404 page.
Fixing this would require additional middleware - I was able to quickly find this one: https://github.com/Lansoweb/basepath.

mtymek commented Dec 19, 2015

This happens because Expressive has no support for "base path" - it puts whole "/path/to/expressive/public" into your router, leading to 404 page.
Fixing this would require additional middleware - I was able to quickly find this one: https://github.com/Lansoweb/basepath.

@samsonasik

This comment has been minimized.

Show comment
Hide comment
@samsonasik

samsonasik Dec 19, 2015

hm.., probably make this a default feature ?

samsonasik commented Dec 19, 2015

hm.., probably make this a default feature ?

@mtymek

This comment has been minimized.

Show comment
Hide comment
@mtymek

mtymek Dec 19, 2015

I would say no. In most cases you will have your application running directly under the domain, without extra path. Development environment is also not a problem since you can use PHP's built-in HTTP server. Detection logic is complex (see here) - while it may be not slowing your application down too much, I don't think it is elegant to have it around if it is not required in 90% cases.

IMO it should be described in a cookbook.

mtymek commented Dec 19, 2015

I would say no. In most cases you will have your application running directly under the domain, without extra path. Development environment is also not a problem since you can use PHP's built-in HTTP server. Detection logic is complex (see here) - while it may be not slowing your application down too much, I don't think it is elegant to have it around if it is not required in 90% cases.

IMO it should be described in a cookbook.

@samsonasik

This comment has been minimized.

Show comment
Hide comment
@samsonasik

samsonasik Dec 19, 2015

@weierophinney any opinion for it?

samsonasik commented Dec 19, 2015

@weierophinney any opinion for it?

@xtreamwayz

This comment has been minimized.

Show comment
Hide comment
@xtreamwayz

xtreamwayz Dec 19, 2015

Member

Not sure if this helps, but you can add RewriteBase to .htaccess.
In your case RewriteBase /path/to/expressive/public.

If that doesn't work there are some more options:

  • use php -S 0.0.0.0:8080 -t public/
  • as mtymek says, use https://github.com/Lansoweb/basepath (I didn't try but it looks like that's what you want to use)
  • in stead of placing projects under localhost/path/to/project/public, configure apache so each project is accessible under sitename.localhost. Then the projects are served from the root and you don't have that issue.

I don't think there shouldn't be a built in option for this since you open up all files in your project. (I hope this is your local server.) e.g. I could access server.com/path/to/expressive/config/autoload/database.local.php

Member

xtreamwayz commented Dec 19, 2015

Not sure if this helps, but you can add RewriteBase to .htaccess.
In your case RewriteBase /path/to/expressive/public.

If that doesn't work there are some more options:

  • use php -S 0.0.0.0:8080 -t public/
  • as mtymek says, use https://github.com/Lansoweb/basepath (I didn't try but it looks like that's what you want to use)
  • in stead of placing projects under localhost/path/to/project/public, configure apache so each project is accessible under sitename.localhost. Then the projects are served from the root and you don't have that issue.

I don't think there shouldn't be a built in option for this since you open up all files in your project. (I hope this is your local server.) e.g. I could access server.com/path/to/expressive/config/autoload/database.local.php

@samsonasik

This comment has been minimized.

Show comment
Hide comment
@samsonasik

samsonasik Dec 20, 2015

RewriteBase doesn't work. Yes, I know about the options, just wondering if we can do like zf2 without vhost or PHP CLI Server.

In live app, the assumption we set config/ folder secure with .htaccess config, so, that can be prevented for user to see.

samsonasik commented Dec 20, 2015

RewriteBase doesn't work. Yes, I know about the options, just wondering if we can do like zf2 without vhost or PHP CLI Server.

In live app, the assumption we set config/ folder secure with .htaccess config, so, that can be prevented for user to see.

@mtymek

This comment has been minimized.

Show comment
Hide comment
@mtymek

mtymek Dec 20, 2015

I built a little project that can help you with serving your app from subdirectories: https://github.com/mtymek/blast-base-url

mtymek commented Dec 20, 2015

I built a little project that can help you with serving your app from subdirectories: https://github.com/mtymek/blast-base-url

@samsonasik

This comment has been minimized.

Show comment
Hide comment
@samsonasik

samsonasik Dec 20, 2015

Thank you! I think it would be great to have it in cookbook ;)

samsonasik commented Dec 20, 2015

Thank you! I think it would be great to have it in cookbook ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment