To redirect requests for www.domain.com to domain.com on an Apache web server, you can use the Redirect
directive in the Apache HTTPD configuration file or in a .htaccess file.
Here is an example of using the Redirect
directive to redirect requests for www.domain.com to domain.com:
Redirect permanent / http://domain.com/
This directive will redirect all requests for www.domain.com to domain.com using the HTTP 301 permanent redirect status code.
Alternatively, you can use the RewriteRule
directive in a .htaccess file to redirect requests for www.domain.com to domain.com, as shown below:
RewriteEngine on RewriteCond %{HTTP_HOST} ^www.domain.com$ RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
This directive will redirect all requests for www.domain.com to domain.com using the HTTP 301 permanent redirect status code.
Keep in mind that the exact syntax and options for the Redirect
and RewriteRule
directives may vary depending on your specific Apache installation and configuration. It is always a good idea to refer to the official Apache documentation for detailed instructions and further information.