Page 1 of 1

rewrite somehow also change the SERVER_PORT value?

Posted: Wed Mar 03, 2010 8:18 pm
by easydev
I setup a rewrite rule simply like:

RewriteRule ^product test.php

And in the test.php, it is as simple as:
<?php
echo $_SERVER["SERVER_PORT"];
?>

If I access http://localhost:6060/test.php directly, I got correct port 6060.
If I access it like http://localhost:6060/product/something.php, I got 80.

Any idea of it?

Thanks a lot.

Re: rewrite somehow also change the SERVER_PORT value?

Posted: Wed Mar 03, 2010 8:54 pm
by requinix
No. What you want is to change something that happened in the past and mod_rewrite can't do that.

Re: rewrite somehow also change the SERVER_PORT value?

Posted: Thu Mar 04, 2010 1:12 pm
by easydev
Do you mean the rewrite does not persevere port number? (or always change it to default 80?)

Re: rewrite somehow also change the SERVER_PORT value?

Posted: Thu Mar 04, 2010 5:36 pm
by requinix
The host and port number are facts you can't change, just like the site the browser is connecting to and the IP address of the server.

To get a different port number you have to have a different port number. That is, http://localhost:80/product/something.php has to exist. Then you can do a proxy request or simply redirect the user to that location.

Now, why would you possibly need to do this?