Does anyone know how to change the URL for a website with htaccess?

I am trying to change the main domain to a new one, all the website will remain the same, except just the main URL. Do I have to 301 every single page manually, or is there a rewrite rule I can use that will make sure all incoming traffic just moves to the same page?


Too easy:

RewriteEngine on RewriteCond %{HTTP_HOST} old\.domain$ [NC] # only necessary if co-located RewriteRule .? http://new.domain%{REQUEST_URI} [R=301,L]

If you’d like to learn more about mod_rewrite (so you can do simple things like this yourself - and KNOW what the code is doing for you), is my tutorial based on many, many years helping members here.



This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.