Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
Server Redirect With Ports?

I don't have much experience with Apache or servers, so my apologies if this is a stupid question. I am trying to redirect http://example.com:5557 to http://203.0.113.111:5557. Is this something I can do in the .htaccess file and, if so, what would that look like?

Here is my idea:

Redirect 301 "http://example.com:5557" "http://203.0.113.111:5557"
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Yes, you can do this in .htaccess, but not with the mod_alias Redirect directive. The Redirect directive matches against the URL-path only. You need to match against the HTTP Host request header, which contains the hostname + port number.

Try the following using mod_rewrite instead:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example\.com:5557$ [NC]
RewriteRule ^$ http://203.0.113.111:5557/ [R=301,L]

Note that this redirects the document root (homepage) only, as stated in your example. If you need to redirect any URL to the same URL at the target domain then use the following RewriteRule instead:

:
RewriteRule ^ http://203.0.113.111:5557%{REQUEST_URI} [R=301,L]

NB: Test first with 302 (temporary) redirect to avoid potential caching issues.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!