Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:12:57+00:00 2026-05-30T23:12:57+00:00

I have a virtual server with one IP address, serving a few different sites.

  • 0

I have a virtual server with one IP address, serving a few different sites. One of them has an SSL certificate on it.

I needed to add an SSL cert on a second domain for private use by myself, and as I only have one IP address, I added it on port 8080 instead. This works fine.

My problem now is that all the domains that point to the server will display my private site if port 8080 is requested on that domain.


https://example1.com:8080/ -> will show my private site, but shouldn't
https://example2.com:8080/ -> will show my private site, but shouldn't
https://desired-domain.com:8080/ -> will show my private site, this is correct!

Anyone visiting https://example1.com:8080/ should be redirected to http://example1.com/, and the same for example2.com.

I tried…


RewriteCond %{HTTP_HOST} !desired\-domain\.com [NC]


RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [L,R=301]

…but the port is appended to HTTP_HOST, so it comes out as http://example1.com:8080/

So, in short, my question: how can I redirect to the requested host, but ignore the request port?


EXTRA

I’ve tried this…


RewriteCond %{HTTP_HOST} !(desired-domain.com):8080$ [NC]


RewriteRule ^(.*)$ http://%1$1 [L,R=301]

…but it redirects to http://localhost/. That’s better than showing the wrong site’s page, though, as nobody should be requesting port 8080 on any other domain anyway!

I suspect there’s a better ‘desired-domain.com’ regex, but my regex-mojo isn’t flowing today.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:12:59+00:00Added an answer on May 30, 2026 at 11:12 pm

    Maybe try:

    RewriteCond %{HTTP_HOST} ^(example[12].com):8080$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
    

    Obviously, you’ll need to be a bit clever about your HTTP_HOST regular expression, if there’s no easy way of encapsulating your example1 and example2 domains within a single regex, you can have 2 of then and use the [OR]:

    RewriteCond %{HTTP_HOST} ^(example1.com):8080$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^(example2.com):8080$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
    

    EDIT:

    You cannot match a backreference like !(desired-domain.com):8080$, as the ! means that it doesn’t match. But you can try something like this:

    RewriteCond %{HTTP_HOST} !^desired-domain.com(:8080)?$ [NC]
    RewriteCond %{HTTP_HOST} ^(.*):8080$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web-server, that serves different domain-names, but has only one IP-address assigned.
On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts
I have a shared development server with many virtual directories running off one of
I have a server that has several virtual machines running on it. I'm trying
I currently have 2 virtual machines running, one is a server and one is
I have virtual hosting with SQL Server. I don't have physical access to SQL
I have a virtual machine running windows 2003 server. It is on a separate
I have an IIS 6 server with a virtual directory pointing to a network
We have a servlet which occupies more virtual memory on the server due to
We have a servlet which occupies more virtual memory on the server as it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.