Problems with mod_rewrite and Browser.QueryParam

0 favourites
  • 3 posts
From the Asset Store
This is a single chapter from the Construct Starter Kit Collection and the Student Workbook from the Workshop.
  • I've deployed my game to a web server, and I'm using mod_rewrite to rewrite paths under the game's folder into a query param - which is in turn then read by the Construct game.

    For the sake of discussion, we can assume that the game is deployed to /foo and that /foo/bar is rewritten into /foo?hello=bar.

    The problem is that Browser.QueryString returns completely empty when this mod_rewrite rule is applied (i.e. while /foo/bar is being rewritten into /foo?hello=bar), whereas if I navigate directly to the param then it works (i.e. if I write /foo?hello=bar directly).

    For troubleshooting purposes I've placed an index.php file in the same folder as the game where I've run var_dump($_GET) to ensure that the param outputs correctly while the mod_rewrite rule is active, and it works as expected.

    So my question is, what could possibly cause Browser.QueryString to return an empty string while mod_rewrite is used, despite the fact that the $_GET variable works just fine outside of the Construct game?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just curious, have you tried sending your query as an ajax request? Don't forget to set your CORS header if you do.

    Which makes me wonder, have you checked the debug console to see if there are any errors. I know a CORS error in the AJAX won't return anything but it will produce a console error.

    I'm not using any mod rewrites but I am using wordpress as a game server. What I do with it is have it look for a specific /foo/bar in any incoming request and if that directory is in the url, I pass the query on to the game server code which returns a JSON. Otherwise, it hands back off to the wordpress code and displays the website.

  • Construct just returns the value of location.search. Try pasting that in to the browser console to see what the browser has it set to. If it's not set to what you expect, it's probably not Construct that's responsible.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)