Basically i have a classic vhost with:
ServerName www.site.com
ServerAlias site.com
I would like to have always $_SERVER['SERVER_NAME'] = 'www.site.com'; even when someone open site.com
Is this possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
No, PHP does not know anything about ServerName, ServerAlias etc.
The proper solution is configuring your webserver to redirect from all your alias domains to the main domain. That’s also a good thing from a SEO point of view.
You can do this e.g. using
mod_rewrite:If you have additional domains, simply setup a separate VirtualHost for them which redirects to your main domain: