-
Notifications
You must be signed in to change notification settings - Fork 275
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
Default url rewrites to /index.php #1072
Conversation
Thains! My usecase is the export-translations URL on GlotPress and it uses URL parameters, so an example URL might be |
…WordPress/wordpress-playground into update/1054-wp-request-rewrites
It will work. This changes the PHP file that is requested, but the headers and globals like I updated the tests to confirm that |
Brilliant, thanks! |
@bgrgicak This solves the problem at hand and the tests pass so let's merge it. Nice! My follow-up question would be: do we still need this code? wordpress-playground/packages/playground/remote/service-worker.ts Lines 51 to 64 in 454fec3
If yes, then #1054 is still relevant and we'll still need to support that logic at the request handler level, otherwise the service worker will rewrite multisite URLs correctly, but other PHP.wasm consumers like WP-NOW and VS Code won't. If not, then #1054 is indeed solved. |
Fixes #1054
What is this PR doing?
If a requested file path can't be resolved (file or folder don't exist) the request file path is rewritten to /index.php.
What problem is it solving?
Ensures a response when requesting WordPress permalink URLs like
/category/uncategorized/
usingphp.request
.How is the problem addressed?
The code assumed that a path which isn't a PHP file is a folder and requested the index.php file in that folder.
In the case of WordPress URLs the path might not be a folder so adding index.php would break a valid request.
To address this, index.php is added to the end of the path only if the path is a valid directory.
If not, the path is rewritten to index.php in the root folder.
Testing Instructions