.htaccess Domain redirect conflicts with addon-domain - wordpress

I have a wordpress blog "old.com" hosted in shared hosting where "old.com" is the main domain...
Then decide to redirect this "old.com" to "new.com" (an addon domain hosted in same hosting)...
I use this code on .htaccess
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$
http://new.com/$1 [R=301,L]
Everything works just fine. I also have an addon domain, "addon1.com" and I still can access this perfectly (I added this "addon1.com" before I redirected "old.com" to "new.com)"
The problem now is, I add "addon2.com" (another addon domain), but I can't access this domain... When I try to access this "addon2.com", it will redirect me to old.com/hxxp://addon.com and shows that the page can't be found....
Can somone help me how to solve this problem? If I remove the redirect code from .htacess, my addon2.com works just fine...
Thanks
Andi
edited
i added this on my .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www.)?addon2.com
RewriteRule (.*) hxxp://new.com/$1 [R=301,L]
and it seems like it works :)

Related

301 Redirect Not Working .htaccess

I have the following redirect code in my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301,NC]
</IfModule>
# END WordPress
AddHandler php-stable .php
I'm trying to redirect all traffic from olddomain to newdomain. Not that the new domain does use "www".
When clicking on an old link elsewhere on the net that would refer to a post, redirect does seem to happen but it does not add in the correct slash after the domain name.
Here is what happens, the link to my old domain is as such on a website (just posted by someone):
http://olddomain.com/some-blog-post/
When I click on that link in a browser, it actually opens up:
http://www.newdomain.comsome-blog-post/
The slash between the domain and the blog post is missing.
Also, if it helps I'm using MediaTemple as my host for the old domain and I'm modifying my .htaccess file in
domains/olddomain.com/html/.htaccess
Anyone have any idea out there? Thanks a ton, I'm stuck.
Ok I just checked on this a little more and it turns out everything is working fine with the .htaccess code I pasted above.
My web browser was caching aggressively and I just had to dump the cache (or use private browsing).
See here for more debugging tips:
Tips for debugging .htaccess rewrite rules
maybe this is better:
RewriteCond %{HTTP_HOST} ^(.*\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ http://%1newdomain.com/$1 [R=301,L]
It matches both the subdomain and request URI and merges them with the new domain. If there is no subdomain, it proceeds to match the request and will redirect without a subdomain.

Wordpress multisites main domain redirecting fails

I have done multisite installation and also created wildcard subdomain. When i type the domain with www the website redirected successfully. However, when i type the domain WITHOUT www, the page gets failed and says no url found. Pls help me with this issue. I am trying hard to get this one success from yesterday.
I have provided the code given in installation to replace in .htaccess file.
I'm in a big hurry. Code for redirecting from non-www to wwww is the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
Add it at the beginning of the file.

Multiple domains on the same WordPress site

I have a Wordpress site runing on Apache and now I want to add another domain adress to this site.
In a few words here... I have two domain names domain1.com and domain2.com .
domain1.com is set and the website is working as it should but now I want to add another domain for the same site. domain2.com, must be redirect to domain1.com, the problem is that I have no idea why it doesn't work, because when I try to access domain2.com it open the following address.
http://domain1.com/wp-signup.php?new=domain2.com
Basically this is a redirect to default domain on signup page. What should I do to fix this?
Hope you understood the question, I don't know how to explain it better.
Edit:
I've added the following rules in .htaccess and restarted apache, but the problem persists. Maybe is something from Wordpress?
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)domain2.com [NC]
RewriteRule ^(.*)$ http://domain1.com/$1 [R=301,L]
OK, looks like all this is wordpress related and apache(htaccess) have nothing to do here. The solution that works for me:
I've added this line in wp-config.php and now it works great. Now if I access domain2.com it is redirected to domain1.com, exactly what I wanted. :)
define( 'NOBLOGREDIRECT', 'http://domain1.com' );
This is what I use for my 301 redirects:
RewriteCond %{HTTP_HOST} ^domain2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain2.com$
RewriteRule ^(.*)$ "http\://www.domain1.net/$1" [R=301,L]
This redirects the domain whether or not people type in the www. part of the url. The backslashes (\) escape the punctuation.
Hope this helps.

Using .htaccess to redirect a domain to another URL

I have a site running wordpress, it's the full site. One of the pages is like a contact-us form located at www.ourdomain.com/contact-us/
I also have a URL like contactourdomain.com and I want it to redirect to www.ourdomain.com/contact-us/
We used to do this with a redirect on network solutions, but I prefer to have it all done right on the server if possible. I've got it sort of working but when you visit the link is still says contactourdomain.com/contact-us/ as the URL, and that breaks all the other ones.
Any suggestions?
.htaccess
Options -MultiViews
RewriteEngine on
RewriteBase /
# Rewrite
RewriteRule ^(.*)$ http://www.ourdomain.com/contact-us//$1 [L]
if you add this in .htaccess is it working?:
RewriteRule ^$ contact-us/ [R=301,L]
keep me posted..

Redirect not working for a drupal multisite installtion

I have a drupal mustisite installation and Im using drupal domain access module. I have sites like www.abc.com and www.cde.com pointing to the same codebase.
However, while redirect for abc.com to www.abc.com works, redirect for cde.com to www.cde.com doesnt work? Any idea on how to fix it?
Im redirecting using htaccess.
The redirect rule I had used previously was not correct. I finally used the one below and it worked like a charm
RewriteCond %{HTTP_HOST} !^www\.cde\.com$ [NC]
RewriteRule ^(.*)$ http://www.cde.com/$1 [R=301,L]
Apologies for inconvenience!

Resources