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 3875340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:15:22+00:00 2026-05-19T22:15:22+00:00

I want to force www. on my URLs (e.g. http://domain.com becomes http://www.domain.com ). However,

  • 0

I want to force “www.” on my URLs (e.g. http://domain.com becomes http://www.domain.com). However, I don’t want it forced on URLs that already have a subdomain (e.g. http://images.domain.com should NOT become http://www.images.domain.com). The following snippet I found on the net does the latter:

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

What do I need to do to get this to work for me? 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-19T22:15:22+00:00Added an answer on May 19, 2026 at 10:15 pm

    Simple
    The rules below force www, except for subdomains.

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

    Edit and paste it, restart apache.

    Explain:

    RewriteCond %{HTTP_HOST} =name.domain [NC] match only when someone types name.domain (your domain name).

    When types subdomain.name.domain the RewriteCond is false and not redirect. You understand?
    In rule that you previously posted you was matching for !(not)^(beginning by)www and subdomain.name.domain satisfied RewriteCond and is what you don’t want. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ONE directory for my entire domain that I want to force https,
My clients want to use 301 redirects to force the 'www' subdomain on their
I have rewrite rule which works on subdomain other than www. I want to
I want to force www in my urls. I'm having problems with writing. I
Is there a parameter I can pass to https://www.facebook.com/dialog/oauth that will force the user
I want to use this great little audio player on a website: http://www.brianhadaway.com/html5-audio-player-with-flash-fallback/ It
I want to force the download of an image. I have found this code:
I want to use autocomplete (jquery or .net) with force a choice so that
Hi I want to make a small test window app that can force IE
Below error occurs with Entity Framework Versions 4.3+ http://www.cnblogs.com/shouzheng/archive/2012/03/09/2388177.html (translated) Use EntityFramework the Code

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.