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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:28:25+00:00 2026-06-05T00:28:25+00:00

Even if in url i write www., $_SERVER[‘HTTP_HOST’] have only domain.com without www. I

  • 0

Even if in url i write “www.”, $_SERVER[‘HTTP_HOST’] have only domain.com without “www.”

I can’t redirect from non-www to www because of this. How to fix this issue?

      ["HTTP_HOST"]=>
      string(8) "ca-fi.ru"
      ["HTTP_COOKIE"]=>
      string(120) "d7b6b86aae18e551749a9da9d54f3daf=floar2lr37318dc76ask49bii5; 849c6485c12558d081c065b4d94a566b=d9iqj8s6oqo41kipg3qaefq497"
      ["HTTP_USER_AGENT"]=>
      string(99) "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5"

      ["PATH"]=>
      string(28) "/usr/local/bin:/usr/bin:/bin"
      ["SERVER_SIGNATURE"]=>
      string(69) "
    Apache/2.2.20 (Ubuntu) Server at ca-fi.ru Port 80

    "
      ["SERVER_SOFTWARE"]=>
      string(22) "Apache/2.2.20 (Ubuntu)"
      ["SERVER_NAME"]=>
      string(8) "ca-fi.ru"
      ["SERVER_ADDR"]=>
      string(13) "192.168.10.12"
      ["SERVER_PORT"]=>
      string(2) "80"
      ["REMOTE_ADDR"]=>
      string(12) "192.168.10.1"
      ["DOCUMENT_ROOT"]=>
      string(8) "/var/www"

      ["REQUEST_METHOD"]=>
      string(3) "GET"

      ["REQUEST_URI"]=>
      string(1) "/"
      ["SCRIPT_NAME"]=>
      string(10) "/index.php"
      ["PHP_SELF"]=>
      string(10) "/index.php"
      ["REQUEST_TIME"]=>
      int(1338819407)
  • 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-05T00:28:28+00:00Added an answer on June 5, 2026 at 12:28 am

    If you just want to redirect from non-www to www, I’d recommend not using PHPs header() function (which I assume you’re using), but to use mod rewrite.

    Create a .htaccess file in your root directory with the following content:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the domain http://www.example.com . When I browse to http://www.example.com/12345 it
I have a blog on BlogSpot.com, and I have a domain based on my
I have a script on my site ('write-review.php') that takes an optional url parameter
In my global.asax.vb file, I have code to re-write the URL if there is
I'm trying to get php to automatically pass the session ID via url, even
Even without a printer-friendly view to print directions, when I choose File->Print in my
Even though it is possible to write generic code in C using void pointer(generic
Even though I have a fermi card(gtx 560) I get this error on VS2010:
So i already have some rewrites in place, but in truth i didn't write
I have to do a site redirect through script for about 10 different URLS

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.