Currently users can access the ourdomain.com BUT i want those visitors to be redirected to www.ourdomain.com
What is the best solution? - We have plesk, linux, apache server running php
Thanks
feedback
|
|
There are a couple of options: if you have a seperate directory/section for ourdomain.com you can use an index.html to redirect your users
you can also use a php program:
This has to be the first lines in your code to be part of the html header | |||
|
feedback
|
|
What the best solution is you'll have to decide -- it does amongst other things come down to what technologies you're most able to maintain. You can do the redirect via Apache's .htaccess, if this isn't disabled on your server (it is most often available, but sometimes its disabled for a slightly better performance / security). Here is a syntax example, and you could google htaccess for more. You can also do the redirect via PHP. The syntax for the redirect itself would be something like:
Note that you'll need your PHP logic to discern between requests that come in with or without 'www.', and only send the header for those without 'www.'. If you're using some sort of 3rd party PHP CMS, then you probably shouldn't change its PHP code. One last thing, if you care about search engine ranking, and you have previously had your site indexed both with and without 'www.', then you should fix that. In Google, log in to Google's Webmaster Tools, and set the canonical URL to the one you prefer, with or without www. For other search engines, inbound links etc, it could be beneficial to contact those who link to you, and have them update their links. | ||||
|
feedback
|
|
Not sure if you can, but perhaps mod_rewrite? | |||
|
feedback
|
|
With mod_rewrite
| |||
|
feedback
|