1

I have an Apache with SSL running on port 444. I need to rewrite all url/requests starts with https://servername ( that is default port 443) to https://servername:444.

I have rule on .htaccess like this:

RewriteCond %{SERVER_PORT} =443
RewriteRule ^(.*)$ https://%{SERVER_NAME}:444%{REQUEST_URI}

This is not working. To check the condition I changed the port on condition as RewriteCond %{SERVER_PORT} =80 and all HTTP requests are forced to HTTPS.

2

If I understand your situation correctly, your problem is that %{SERVER_PORT} is never equal to 443, since your server is not listening on that port. Thus, your RewriteCond %{SERVER_PORT}=443 condition will never be true.

In fact, I don't believe it is possible to do the rewrite that you intend, unless you put a server listening at port 443 just to handle the initial incoming requests that you then immediately redirect to port 444. But if you do that, you might as well not bother redirecting at all; just handle the HTTPS requests at 443.

  • yes you are right. I too felt the same. – user37143 Oct 28 '10 at 7:11
  • I am going to try a Proxy forward from 443 to 444. – user37143 Oct 28 '10 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.