Redirecting a Domain via htaccess File

The .htaccess file is a configuration file used by Apache web servers to control various aspects of website behavior. It allows you to modify server settings, enable/disable features, and perform URL rewriting, including domain redirection.

  • Connect to your web server using FTP or a file manager.
  • Locate the root directory of your domain. The root directory is named public_html, www, or the domain name itself.
  • Look for the .htaccess file (if it doesn't exist, create a new file and name it ".htaccess").
  • Create a backup of the existing .htaccess file. This allows you to revert back to the original file if needed.
  • Open the .htaccess file and add the following lines of code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]

Replace "yourdomain.com" with your current domain and "newdomain.com" with the destination domain. The above code redirects all requests from the old domain to the corresponding URL on the new domain.

  • Save the .htaccess file and upload it to the root directory of your domain.
  • Upload the edited or new .htaccess file to your server using FTP or the file manager.
  • Test the redirect by entering the original domain in a web browser, and ensure the redirect is functioning correctly.

Working with the .htaccess file requires attention to detail, as misconfigurations can lead to website errors or disruptions.

  • Redirecting a Domain, Redirecting a Domain via htaccess File, Domain via htaccess
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What are .ph domains?

Basically, .ph domains are for companies or organizations located in the Philippines. If the .com...

Domain Name Cancellation

We do not allow cancellation or refund once a domain name has been registered or activated....

How to check Domain Availability?

Do you have a domain name in mind and you want to check whether it is available or has already...

What are Domain Names?

Domain names are used to locate websites and/or email on the internet. It is your unique address...

How to update Name Servers for PH Domains (.ph, .com.ph, .net.ph)?

Please log in at https://gomanilahost.net/clients/clientarea.php to manage your domain.