How Can I accomplish this with .htaccess? I tried a couple of different htaccess modifications, but none worked. The old domain is a wordpress blog. I want all that traffic to go the root domain of the new website. Example: http://www.olddomain.com/?p=8 http://www.olddomain.com/?page_id=2 http://www.olddomain.com/ http://www.olddomain.com/?cat=1 http://www.olddomain.com/?m=200811 ALL TO http://www.NEWDOMAIN.com/
hello add this lines in .htaccess in olddomain.com RewriteEngine on RewriteCond %{HTTP_HOST} !^www.newdomain.com$ RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301] and all visit are sent to newdomain Best
I tried this one before. Doesn't work properly. Redirects olddomain.com/?p=8 to newdomain.com/?p=8, but I want olddomain.com/?p=8 to newdomain.com (root)
well here is the code to redirect all to main domain RewriteEngine on RewriteCond %{HTTP_HOST} !^www.newdomain.com$ RewriteRule ^(.*)$ http://www.newdomain.com/ [R=301]
Finally solved it, so here is the solution for any potential future readers. The problem is that with standard wordpress you get permalinks with question marks in url, which makes the URL into a query string, which is handled differently than normal forwarding requests in an .htaccess file. The solution is to put a question mark at the end of the RewriteRule. So in this specific case, the file now looks like: RewriteEngine on RewriteCond %{HTTP_HOST} ^.*olddomain.com$ [NC] RewriteRule ^(.*)$ http://www.newdomain.com? [R=301,L]
I know this thread is a little old, but I've searched all the other threads on DP and other sites as well and the above example is the best if you are trying to redirect ALL of the pages including inner pages of your site to a new URL. If you have taken a site down that is receiving traffic to various pages of your site and you don't want to simply forward the domain to a new url then add this to an .htaccess file in the root directory: