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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:39:31+00:00 2026-06-05T01:39:31+00:00

This is a common problem, and there many common answers for this, but I

  • 0

This is a common problem, and there many common answers for this, but I have a specific small detail that does not work and reading documentation does not help me to understand the reason.

So, here is the problem: I want to remove www. from a domain name. I use .htaccess with mod_rewrite. Here is the code:

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

It works, if I just type http://www.swedish-cloud.com. It changes it to http://swedish-cloud.com.

But if I type, for example: http://www.swedish-cloud.com/index.html, it does not change the URL to http://swedish-cloud.com/index.html

However, if I type a path to a non-existing file, like http://www.swedish-cloud.com/index2.html, it change the URL to http://swedish-cloud.com/index2.html showing a 404 Not Found error.

Can you please let me understand what I am missing? Thank you.

PS: I don’t have the root access to the server.

  • 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-06-05T01:39:35+00:00Added an answer on June 5, 2026 at 1:39 am

    Let’s give you the correct answer. Your syntax for the cond is wrong but not significantly and the syntax for the rule is also wrong. Try:

    RewriteCond %{HTTP_HOST} =www.swedish-cloud.com
    RewriteRule ^.*          http://swedish-cloud.com/$0   [R=301,L]
    

    Use an equality operator in the cond if that is want you want to do and then you don’t need to escape the match string.

    The replacement string doesn’t need quotes or escapes and since you want the entire URI, why not just use $0 (the entire match pattern).

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

Sidebar

Related Questions

I feel like this is a common problem but nothing I've researched has worked
This seems to be a common problem, but I cant seem to fin a
This must be a common problem with a common solution. I have a lot
This is a fairly common problem to which I have yet to find an
This is a slightly original variation on a common problem. I have a fairly
This must be a common problem because I see it in many published papers
I'm sure this is a common problem for many web applications these days. What
I hope I'm not writing a duplicate, but I haven't found anything that answers
We have many projects that use a common base of shared components (dlls). Currently
I have a requirement that I think is common in many applications: paging. I

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.