|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-21 14:37 UTC] ruslan dot kyrychuk at gmail dot com
Description:
------------
With apache redirects (mode_rewrite) then in $_SERVER['SERVER_PORT'] is always 80, even if Apache server is working on another port.
Reproduce code:
---------------
While apache redirect with following rewrite rule
RewriteRule ^(.+)$ index.php [QSA,L]
Then $_SERVER['SERVER_PORT'] is "80"
---
P.S. While
RewriteRule ^(.+)$ index.php [E=PORT:%{SERVER_PORT},QSA,L]
then $_SERVER['REDIRECT_PORT'] is "8080"
So it looks like redirected value is sending correctly but doesn't save correctly into $_SERVER array.
Expected result:
----------------
RewriteRule ^(.+)$ index.php [QSA,L]
During redirecting
$_SERVER['SERVER_PORT'] must be correct port.
Actual result:
--------------
$_SERVER['SERVER_PORT'] is always "80" during apache redirect.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 12:00:01 2025 UTC |
Reproduce code: --------------- 1. Configure Apache to use port 8080 2. Create .htaccess file: Options +FollowSymLinks -Indexes RewriteEngine on RewriteCond %{REQUEST_FILENAME} (.+)\.html RewriteRule ^(.+)$ test.php [QSA,L] 3. Create test.php file <?php echo $_SERVER['SERVER_PORT']; ?> Run http://localhost:8080/test.html Output: 80 Run http://localhost:8080/test.php Output: 8080Yes, mono on windows produce same results - so it not PHP. Workaround was alredy written RewriteRule ^(.+)$ index.php [E=PORT:%{SERVER_PORT},QSA,L] then read $_SERVER['REDIRECT_PORT']