How do i Grab the response url?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
baoky
Forum Newbie
Posts: 12
Joined: Sat May 24, 2008 6:21 am

How do i Grab the response url?

Post by baoky »

Hi , i want to ask about php coding.

Basically i enter a url like example http://my-domain.com/goto1.php?s=111a and it redirect me to http://my-domain.com/111.html

how do i grab this http://my-domain.com/111.html which is the response url and assign this value to a variable

I need to store the response url as a variable and use it , thanks in advance!
soulcrazy
Forum Newbie
Posts: 13
Joined: Sun Aug 24, 2008 10:05 pm
Location: Ontario, Canada

Re: How do i Grab the response url?

Post by soulcrazy »

baoky wrote:Hi , i want to ask about php coding.

Basically i enter a url like example http://my-domain.com/goto1.php?s=111a and it redirect me to http://my-domain.com/111.html

how do i grab this http://my-domain.com/111.html which is the response url and assign this value to a variable

I need to store the response url as a variable and use it , thanks in advance!

I'm no quite sure I understand what you're doing.
You have a link on your site: <a href="http://my-domain.com/goto1.php?s=111a">link</a>
And you want to (without clicking it...so programmically/dynamically) get the url it would redirect you to: http://my-domain.com/111.html

?

Are you setting this variable from http://my-domain.com/goto1.php?s=111a? or when you get to http://my-domain.com/111.html?

If you load the page http://my-domain.com/111.html, in an iFrame on http://my-domain.com/goto1.php?s=111a, you can, with JavaScript, get that iFrames URL and set it as a cookie to later be read via PHP.

Code: Select all

 
echo $_SERVER['SERVER_NAME']; // may help...on this site, this func would return something like: forums.devnetwork.net/posting.php?mode=quote&f=1&p=481042 (getting http or https is another function).
 
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: How do i Grab the response url?

Post by Ziq »

If I have correctly understood look at mod_rewrite

For example create .htaccess file in root directory (folder this index.php)

Code: Select all

 
RewriteEngine on
RewriteRule ^([0-9]+).html$ http://my-domain.com/goto1.php?s=$1
 
Post Reply