I have a domain/website that I want to redirect all URL’s to one page on another domain through .htaccess.
Example:
www.domain.com to redirect to www.newdomain.com/webpage.html (that’s what I have know)
But I also want to redirect www.domain.com/$ to redirect to www.newdomain.com/webpage.html (where the $ is any page).
Basically, any page visited to www.domain.com should be redirected to www.newdomain.com/webpage.html.
Thanks.
Thanks Mike,
I have found a cleaner piece of code that works really well now.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/page.html [R=301,L]
thanks for an update Jack!
Example using htaccess:
Redirect 301 / http://www.newdomain.com/page.html
Example using mod_rewrite:
RewriteEngine On
rewritecond %{http_host} ^olddomain.com
rewriteRule ^(.*) http://www.newdomain.com/page.html [R=301,L]
As for the htaccess redirect the new pages must not be in a subdirectory of the htaccess file. But if you are on a different host/account this won't concern you.
Jack, works perfect for me! Thanks man!
I have solved my issue, but I am sure there is a better, more efficient way.
My .htaccess file contains:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^/?$ "http://www.newdomain.com/page.html" [R=301,L]
ErrorDocument 404 http://www.newdomain.org/page.html
--
If you know have a cleaner way, please let me know