I want to redirect a request on my apache server at ' http://example.com ' to ' http://www.example.com ' . I have added as alias but it doesn't work . Please guide me.
You can do the redirect by adding .htaccess file in your root directory with this content:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This will force redirect all requests to www.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.