I am presently attempting to reconfigure a Apache server to have the ability to use another port than 80 when being able to access a web page, after which based on what port a request ended I actually do some .htaccess miracle. There's no issues with reconfiguring the Vhost and listen holiday to a port, but for whatever reason all non-ssl demands will always be construed as visiting port 80.

Basically attempt to open the page my.site.com:8080 my log shows something similar to this

my.site.com:80 my.ip. - - [23/Jan/2012:14:37:24 +0100] "GET /images/pagenav_bg.presen HTTP/1.1" 200 2484 "http://my.site.com:8080/css/all.css" "Mozilla/5. (Home windows NT 6.1 WOW64 rv:8..1) Gecko/20100101 Opera/8..1"

My .htaccessrules which have the problem "RewriteCond % ^80$" takes over, and PHP $_SERVER['SERVER_PORT'] shows port 80.

I have attempted with various ports and I have even disabled listening on port 80, which provides the expected result that my.site.com reduces, but my.site.com:8080 still works.

To be obvious concerning the questing: How do you enable/reconfigure apache to ensure that the "real" port number can be used?

Edit: I simply discovered this may have related to mod_rewrite. However I haven't discovered how you can circumvent it. I additionally think it is a little strange that .htaccess interpretates the main harbour as 80 before any rewrite rules run.

Edit2: After more experimentation I have subtracted that the issue is most likely during my .htaccess file. Right now it appears such as this

RewriteEngine On

#Rewrite rule to allow normal access to existing files
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

#The normal rewriterule for the framework that is used
RewriteRule ^.*$ index.php [NC,L]

In my opinion this is happening. Once the rewrite is performed it is going from http://my.site.com:8080/some/url to become construed as my.site.com/index.php by Apache, which automatically is port 80. I have to rewrite it to my.site.com:8080/index.php rather. The next snipped doesn't work however.

RewriteCond %{SERVER_PORT} ^8080$
RewriteRule ^(.*)$ http://my.site.com:%{SERVER_PORT}/index.php [NC,L]

I have found the solution and also the redirects now work properly. Regrettably which means that I must hard-code my redirects, however in this situation it's acceptable.

The issue was, as referred to within the edit to my question above, Apache and also the .htaccess where my.site.com:8080/some/url was rewritten to my.site.com/index.php, and never my.site.com:8080/index.php.

it was solved with the addition of one rule for every port in which a specific situation was needed for example

RewriteCond %{SERVER_PORT} ^8080$
RewriteRule ^(.*)$ http://my.other.site.com:%{SERVER_PORT}/index.php [NC,L]

As observed in my edits within the original questions, this didn't work on first, but which was only because my rules arrived the incorrect order. Problem solved.