1

We usually send data to another page using variables in URL. An example is http://www.somelink.com?var1=data1&var2=data2. And we receive the data using $_GET['var1'] and $_GET['var2'].

How can I achieve this in using standard slash format. What I need is similar to http://www.somelink.com/var1-data1-var2-data2

I got this idea on seeing this link: http://freelivebox.eu/matchid-130102021307-link-5-watch-Youzhny---Davydenko-(ATP-Doha).html

4
  • Are you running on apache? Commented Jan 2, 2013 at 14:44
  • 5
    Read up on URL rewriting Commented Jan 2, 2013 at 14:44
  • If you haven't explored this option yet, you may be able to use session variables or cookies to achieve your goal. But if you need to have your URL displaying your variables then URL Rewriting would be what you need to look into. Commented Jan 2, 2013 at 14:48
  • @Guy Ya, Apache and pages are PHP pages Commented Jan 2, 2013 at 14:48

2 Answers 2

3

You can do it with .htaccess file like below

RewriteRule ^var1-([a-zA-Z0-9-]+)$-var2-([a-zA-Z0-9-]+)$  youpage.php?var1=$1&var2=$2;

or you can can split it regular expression-

Sign up to request clarification or add additional context in comments.

Comments

2

The best way I could think of is by using some sort of Regular Expression matching that all gets routed through a single PHP routing file.

Or by using Apache's rewrite capabilities.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.