← Linux
Add a Redirect Script to your .htaccess File
Updated 12 Oct 2026 · 47,643 views
This support article walks you through the process of adding a redirect to your .htaccess file. You can use this script to redirect your site to www.domain.com or to a different domain altogether.
- Add the following code to your .htaccess file:
- Upload the .htaccess file to your web root or another appropriate directory.
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Replace domain.com and www.domain.com with the your domain name and the destination URL respectively.
Did this answer your question?
Thank you. % of readers found this helpful.
Related
Installing htop
Bind Multiple IP Addresses to a Single Network Interface Card (NIC)
Clear Memory Cache on Linux Server
Set the time on a Linux server
Check your disk usage in Linux
Still stuck?
Open a ticket