0

So I want to be able to set up a single PHP script that can handle requests to unique urls. In this case, the user is submitting a join id code. For example, with $_GET they could go to example.com/join?code=abc123 and I could easily get the code with $_GET['code'] which would be set to "abc123". However, I want to set up a system where they can join with a url like the following: example.com/join/abc123. I do not know how to get the abc123 code from that url. I want all of this to be handled from a single script, ex. join.php.

Zach P
  • 560
  • 10
  • 30
  • 1
    If you want to pull `abc123` from it, then use `parse_url()`. http://php.net/manual/en/function.parse-url.php – Funk Forty Niner Feb 19 '16 at 02:50
  • Zach, your question's a tad bit unclear. You want to pull `abc123` but use a mod rewrite, correct? Pretty sure that's what you need here then. – Funk Forty Niner Feb 19 '16 at 02:57
  • I have the mod rewrite all set up so that I remove the `.php`, but I am still unclear of how to pull the `abc123` – Zach P Feb 19 '16 at 02:58
  • 1
    `parse_url()` http://php.net/manual/en/function.parse-url.php see http://stackoverflow.com/a/19193610/ could be of help and other answers in the same question. TBH, I'm not so hot with `.htaccess` stuff. – Funk Forty Niner Feb 19 '16 at 03:01
  • I understand how the `parse_url()` function works but I am unclear where I would put the code that uses that function. If I go to `example.com/join/abc123` it is going to give me a 404 error. How would I be able to put the code in `example.com/join` so that I could get all the data after `/join/` in a single file, if that makes sense – Zach P Feb 19 '16 at 03:03
  • What exactly is your problem? if you think its mod-rewrite related then why don't you post the code? – Amit Verma Feb 19 '16 at 03:08
  • It is not mod-rewrite related (I think). – Zach P Feb 19 '16 at 03:09
  • I found an answer here: http://stackoverflow.com/questions/16388959/url-rewriting-with-php Thanks for the help – Zach P Feb 19 '16 at 03:13

0 Answers0