davis Posted February 12, 2012 Share Posted February 12, 2012 Why is my directory opening as http://mydomain.com instead of http://www.mydomain.com when i type mydomain.com in the browser? I have to say that in my admin settings the url is set to http://www.mydomain.com/. Quote Link to comment https://forums.phpfreaks.com/topic/256972-phpld-default-url-issue/ Share on other sites More sharing options...
gizmola Posted February 12, 2012 Share Posted February 12, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/256972-phpld-default-url-issue/#findComment-1317361 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.