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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:42:57+00:00 2026-06-02T16:42:57+00:00

I need to redirect every http://test.com request to http://www.test.com . How can this be

  • 0

I need to redirect every http://test.com request to http://www.test.com. How can this be done.

In the server block I tried adding

rewrite ^/(.*) http://www.test.com/$1 permanent;

but in browser it says

The page isn’t redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

My server block looks like

 server {
            listen       80;
            server_name  test.com;
            client_max_body_size   10M;
            client_body_buffer_size   128k;

            root       /home/test/test/public;
            passenger_enabled on;
            rails_env production;

            #rewrite ^/(.*) http://www.test.com/$1 permanent;
            #rewrite ^(.*)$ $scheme://www.test.com$1;

            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                    root   html;
            }
    }
  • 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-02T16:42:58+00:00Added an answer on June 2, 2026 at 4:42 pm

    Best way to do what you want is to add another server block:

    server {
            #implemented by default, change if you need different ip or port
            #listen *:80 | *:8000;
            server_name test.com;
            return 301 $scheme://www.test.com$request_uri;
    }
    

    And edit your main server block server_name variable as following:

    server_name  www.test.com;
    

    Important: New server block is the right way to do this, if is evil. You must use locations and servers instead of if if it’s possible. Rewrite is sometimes evil too, so replaced it with return.

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

Sidebar

Related Questions

I need to redirect any www.mysite.com/anything/anything OR www.mysite.com/anything AND EXCLUDE www.mysite.com/app TO www.mysite.com/app Of
I need to redirect if someone goes to any folder e.g. http://site.com/images/ or http://site.com/images
There is a page with two domains: www.exampleone.com www.exampletwo.com I need a redirect to
I have my server's apache configured to redirect every request into index.php, so that
Trying to add trailing slash to every link. i.e. http://mysite.com/products should make 301 redirect
I need to redirect any URLs without www. to URLs with www. for better
I need to redirect non-www to www, with correct URL params. A lot of
I need a URL to just test basic http connectivity. It needs to be
I want to write a MobileSubstrate ( http://www.iphonedevwiki.net/index.php/MobileSubstrate ) addon that takes every HTTP
Edited: To better explain what i want. We want to move our frontpage http://www.example.com

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.