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

  • Home
  • SEARCH
  • 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 6934425
In Process

The Archive Base Latest Questions

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

There seem to be a million posts on StackOverflow on this topic, but none

  • 0

There seem to be a million posts on StackOverflow on this topic, but none seem to be exactly what I’m after.

Basically, I’m trying to redirect all random non-existent subdomains to the “www” version of a URL.

For example, if someone types “whatever.mydomain.com” in the address bar, this should redirect to “www.mydomain.com”. This is also a WordPress driven site, so I’m wondering if WP’s existing rewrite rules are causing the redirect loops that have happened with many of the pieces of code I’ve tried.

It should also be noted that currently the site redirects from the non-www version to the www version, but I can’t for the life of me find where that is occurring. It’s not in the .htaccess file, and I don’t know where else to look for that.

Thanks.

  • 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-27T11:57:31+00:00Added an answer on May 27, 2026 at 11:57 am

    Try adding this at the top of your .htaccess file in the root folder of mydomain.com

    RewriteEngine on
    RewriteBase /
    
    #for all requests on mydomain.com
    RewriteCond %{HTTP_HOST} mydomain\.com$ [NC]
    #if they are not for the www.mydomain.com
    RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
    #301 redirect to www.mydomain.com
    RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There must a million variations of this problem but I don't seem to be
There seem to many ways to skin this particular cat - but which is
This may not seem like a development question but there is a link. I
I'm sure there's a million questions along this line but I can't find one
ok, I know this is asked a million times, but I still can't seem
There seem to be no property for an image to use at all, even
I know the title may seem strange but this is what I want to
This may seem a silly question, but having been pondering it for a few
There seem to be many ways to define singletons in Python. Is there a
There seem to be two rival Eclipse plugins for integrating with Maven: m2Eclipse and

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.