Jump to content

Recommended Posts

The browser is reponsible for passing the hostname.  So long as your site supports resolution of mydomain.com, you get a webpage there, which is undoubtedly what you want. 

 

To redirect all requests for mydomain.com to www.mydomain.com you can forward them, using one of a number of techniques.  With apache people frequently use mod_rewrite rules.  As this is usuallly an SEO optimization seeking to insure that engines don't split results for the same thing due to subdomain confusion, the way to handle this is to have your webserver issue a 301 response, which tells the client that the url they are requesting has moved permanently.  This will cause search engines to make sure that they aggregate/combine all their indexing to the desired domain.  Here's a typical mod_rewrite ruleset:

 

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

 

Your framework could implement this type of thing itself, but it's faster and more efficient in most cases to use mod_rewrite.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.