-
Notifications
You must be signed in to change notification settings - Fork 5
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
Route only takes absolute path #17
Comments
Hi, @blebon-km. If you are using docker, i think this is provided to you by default, but if you are not, try this solution. For your first problem, can you give me more details about your environment? |
Hello, I think you misunderstood my "problem", so I'll explain with an example:
Then, when I type the URL http://localhost/my/subfolder/wordpress/hello I expect to see the message "Hello" but instead I get a 404 error. To make it work, I need to change my code to replace the relative path with an absolute path like this:
This can be annoying because in a production environnent the URL of my wordpress won't be the same so I'll have to change all my routes to make it work. |
@blebon-km Thanks for reporting! This is a know problem actually, I'll give you a heads up when I do the fix. For now I advice you to create a subdomain to your subfolder installation, if it's possible. Sorry about that! |
@blebon-km Alter is built on top of FastRoute, please take a look on this issue and tell me if any of the solutions works. |
Actually I took a look in the Ampersand project (the Route.php file) and I think the problem might be either located in the addRoute method around the line 134:
The $_route variable contains a relative path so maybe we should turn it into an absolute path ? or either in the parse_request method around the line 265:
At this moment the $uri variable contains the absolute path, so it won't match any route that has a relative path. But I'm not sure if these are the right places to fix this "problem". What's your opinion about it ? Anyway, there's also a workaround that consists in nesting all the routes in a Route::group that has the base URI of the application as a path which simplify a lot the transition between the development and the production environment. |
@blebon-km sorry for the long delay! This should be fixed in Ampersand's latest release. |
If your wordpress is not located at the root of your webserver you must specify the absolute path in each routes which is, in my opinion, counterintuitive. The application should behave the same way whether it's located at the root or in a subfolder of the webserver !
Actually it took me time to understand why my routing wasn't working ! If you don't plan to fix it immediatly I think it could be nice to have a few words about it in the documentation ;)
The text was updated successfully, but these errors were encountered: