I need to use the HTTP_HOST header in a RewriteRule but change the port
I cannot use SERVER_NAME as it will be different from the host header (which is what I need)
Is there a way to trim the :port off of the HTTP_HOST variable for mod_rewrite?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you can trim the port off of the host header. Just match against
%{HTTP_HOST}and use a%1backreference. For example:Just keep in mind that the
%1backreference can only be used in the first parameter of aRewriteCond, and not in a match:is ok
is NOT ok