How to redirect all users from one website to another using .htaccess
To redirect all users from one website to another using .htaccess
, you can use the Redirect
directive. Here's a simple example:
RewriteEngine On RewriteRule ^ https://www.newwebsite.com/ [R=301,L]
This rule assumes that you have the mod_rewrite
module enabled on your Apache server. If it's not enabled, you can usually enable it in your server configuration.
This rule will redirect all requests to https://www.oldwebsite.com
to https://www.newwebsite.com/
with a 301 (permanent) redirect. The L
flag indicates that this is the last rule to be processed.
Make sure to replace https://www.newwebsite.com/
with the actual URL of the website you want to redirect to.
Please note that modifying the .htaccess
file can have serious consequences if not done correctly, so it's always a good idea to create a backup before making changes. Additionally, if you don't have access to the server configuration, make sure that your hosting provider allows the use of .htaccess
files for such configurations.