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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:41:27+00:00 2026-05-20T14:41:27+00:00

RE: .htaccess – how to force "www." in a generic way? I asked this

  • 0

RE: .htaccess – how to force "www." in a generic way?

I asked this question before, and got this answer:

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

It works, but now I am seeing 301 Moved Permanently in the response headers. I want to eliminate the 301s. Is the problem the 2nd rewrite condition? Should it be something like “does not start with ‘www.’ followed by the host name”?

By the way, I want this solution to work for any server (meaning, I don’t want to hard code my domain name).

Suggestions?

UPDATE:

I just realized that the above is not working correctly. If I have the following:

http://images.domain.com

I don’t want that to change to:

http://www.images.domain.com

I don’t want this affecting sub-domains. I only want it to affect missing www.

  • 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-20T14:41:28+00:00Added an answer on May 20, 2026 at 2:41 pm

    Redirecting to a different domain is by definition not possible without some header redirect. If you want the URL in the user’s browser to change, you have to force a new request. There is no way around that.

    You will have to take your pick – the 301, 302 and 303 status codes being the most straight forward choices.

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

Sidebar

Related Questions

my .htaccess file contains the following RewriteCond %{HTTP_HOST} ^www\.mydomain\.org\.in [NC] RewriteRule ^(.*)$ http://mydomain.org.in/$1 [R=301,L]
My .htaccess file is as follows: Options -Multiviews RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule
My .htaccess file is as follows: Options -Multiviews RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule
My .htaccess file is as follows: Options -Multiviews RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule
My .htaccess file looks like this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f
My .htaccess looks like this: RewriteEngine on RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)|(\.swf)|(\.xpi)|(\.ico)|(\.src)$ RewriteCond %{REQUEST_URI} ^(.*)$ #RewriteCond
I'm a .htaccess nOOb, but I think this is the best way to do
.htaccess: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} ^site\.com$ [NC] RewriteRule ^(.*)$
The htaccess file below crashed the site with an internal server error (500). This
Using .htaccess how can I force only my IP address to return a 502

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.