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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:40:22+00:00 2026-05-14T18:40:22+00:00

I have a .htaccess redirect for non www like this: RewriteEngine on RewriteCond %{HTTP_HOST}

  • 0

I have a .htaccess redirect for “non www” like this:

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

it is working. But, i have also some subdomains other than www.
If I call for example http://shop.example.com it redirects me to:
http://www.shop.example.com

I dont want to write the subdomains into the .htaccess file, it should work automatically, just ignore anything else than www and ” like this:

if subdomain =='' -> redirect to www.HTTP_HOST....
elseif subdomain !='' && subdomain !='www' -> do nothing.

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-14T18:40:22+00:00Added an answer on May 14, 2026 at 6:40 pm

    try this:

    Options +FollowSymlinks
    
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST}//s%{HTTPS} ^www\.(.*)//((s)on|s.*)$ [NC]
    
    RewriteRule ^ http%3://%1%{REQUEST_URI} [L,R=301]
    

    Just tried it with internetagentur.drupal-webmaster.de (the subdomain) – the main is without www.

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

Sidebar

Related Questions

I have the following in my .htaccess to redirect non-www to www: RewriteCond %{HTTP_HOST}
I have this htaccess rule to redirect my page to data_parser.php RewriteEngine On RewriteRule
I am using htaccess to redirect non-www to www like this: user typea: mydomain.com
I have a simple .htaccess which redirect non www to www domain RewriteEngine on
I have the following in a .htaccess file redirect 301 /page.php http://domain.com/page Which works
have such kind of error. When adding Redirect 301 rule to .htaccess file like:
I have such .htaccess file: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php
I currently have: RewriteCond %{HTTP_HOST} ^www.domain.com [NC,OR] RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com [NC,OR] RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.co.uk
In my website root I have the following to redirect to non www domain
I'd like to redirect http://www.mydomain.com/service to http://www.mydomain.com:PORT where PORT is the port of the

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.