Redirect htaccess [closed]

First off, most of the following is speculation, since there are a few details that are unknown. What’s happening when it doesn’t work? Anything? Nothing?

Also, are you trying to redirect only the home page or have you moved the whole site to this new domain name?

If you are trying to point everything from https://example.com to the new domain (for example, https://example.com/blog will also redirect to https://xmpl.com/blog) you can do this:

Redirect 301 / https://xmpl.com/

The 301 error says everything has been permanently moved to the new site. The first param “/” says “everything at the current url” the second param says “this new domain”. (Remember the www matters! https://xmpl.com is not the same as https://www.xmpl.com)

If it is only the home page you want to redirect – so https://example.com/blog should still go to https://example.com/blog, BUT https://example.com should go to https://xmpl.com you can use regex:

RedirectMatch "^/$" "https://xmple.com"

This will match only for the domain root and send it to the new url. Again, www matters. See more helpful regex/mod-rewrite stuff here: https://cheatography.com/davechild/cheat-sheets/mod-rewrite/

Also helpful to know: For the redirect parameters,the first path (to the old file) must be a local path, NOT the full path. So if your .htaccess file is in the directory /example.com, you would not include /home/username/example.com in the local path. The first / represents the example.com directory. If the old file was in that directory, you would follow the / with the old file name. The second path references the new file you want to land at. In your case, the second path is going to be a full URL, referencing a place on a different server, but (for future reference) it can also be a local path.

I hope this helps!