Help with simple URL parse and re-direct

I’m a newbie when it comes to PHP, and I’m looking for help doing what I think should be pretty simple. I have a query string in the format of 9SJN25-30-10 that I want to be able to pass to one URL (e.g., www.example.com/?q=9SJN25-30-10. I want to be able to automatically parse that URL and re-direct to another URL in the following format: www.domain.com/journal/year9/issue25/article30/page10/ where the numbers are pulled from the query string and inserted as shown in the previous example.

It would be especially nice if the re-direct script would display an error message if the input query is not strictly in the format of #SJN#-#-# (with # representing a number that is one or more digits long).

Any help would be greatly appreciated!

Seems simple enough - Show me what you tried so far and we can go from there .

If you haven’t tried anything, look at all the different string functions in PHP and give it a go…

https://php.net/ref.strings

When you get stuck, post your code and I’ll help ya.

While doing what you are wanting isn’t that complicated, do you have a router in place to handle a url that looks like this, www.domain.com/journal/year9/issue25/article30/page10/?

Sponsor our Newsletter | Privacy Policy | Terms of Service