Multiple domains in Drupal - drupal

I have a Drupal website. It's domain is example.com. I want domains: mysite.com and mywebsite.com to point to example.com website.
How to setup multiple domains that point to one website?

You can add ServerAlias to your Apache conf for that virtual host. That is one way. You could also forward the domains with DNS.

I used 301 redirect in .htaccess.
I added thes two lines to .htaccess file in Drupal root:
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Now www.mysite.com goes to www.example.com
I also added Domain Aliases in Plesk Panel.
Thanks a lot!

DomainAccess module is your friend here. While it's probably overkill in this case, it'll be there for you if you ever want to specialize (like change the title or theme based on what domain you're on).

Related

Redirect domain.nl/pages to domain.com/nl/pages

I stopped using domain.com as DocumentRoot for domain.nl as the WPML setup (WordPress Multilingual) with two domains each loading a single language from one DocumentRoot / CMS could not be done by Dreamhost admins and is no longer really condoned by Dreamhost on managed VPS as it requires customization of httpd.conf or working with custom vhosts. This they no longer allow on managed VPS and I understand.
I now work with one domain with the other language (nl) in a subdirectory of the .com domain. All still managed from one WP CMS using WPML
So I now I added a .htaccess to domain.nl with
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.nl$ [OR]
RewriteCond %{HTTP_HOST} ^domain.com.com$
RewriteRule (.*)$ https://domain.com/nl/$1 [R=301,L]
</IfModule>
I added this to stop customers from seeing 404s for pages like https://domain.nl/category/very-long-post-name/ where they should see https://domain.com/nl/category/very-long-post-name/
I do not see it redirecting yet. It still 404s at https://www.domain.nl/category/very-long-post-name/
Any ideas how I can fix this?
Well for all those who bump into similar issues working with mirroring of domains or using ServerAliasing and or changing of the DocumentRoot (web directory in Dreamhost) to use WordPress with WPML and two domains loading two languages.
Do not forget to do these changes or or undo them for HTTPS as well. Not only for HTTP. In the Dreamhost panel there are two locations under domains > manage domains. One for HTTP and one for HTTPS. Single last column is for HTTPS
For other hosters the places are probably different or you have to do it manually

How to access my single wordpress site via multiple sub-domain

I want to access my single worpress installation site via multiple subdomain without using multisite functionality.
What i have tried, but i have not found the perfect solution:
I have used the MultiDomain plugin but it restricted me to add the multiple domain in array through hardcode, actually i want the subdomain ui plugins that help me to add multiple subdomain like "myname.example.com" to redirect in main wordpress website i.e "example.com".
Thanks in advance
You can configure that easily in apache using NameVirtualHost, no need for a WordPress plugin.
<VirtualHost *:80>
ServerName *.example.com
# for a single subdomain:
#ServerAlias myname.example.com
Redirect permanent / http://example.com
</VirtualHost>
If you don't have direct access to your apache config, you can configure *.example.com to it's own document root (how to do that depends on you hoster, can't give you any concrete examples) and configure the redirect in a .htaccess file:
RewriteEngine On
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

Apache redirect to another server keeping browser address

A have a custom website based on apache/php. I also have a wordpress blog and I would like it to be hosted in a different server.
I have tried to create a sub-domine like http://blog.mydomine.com but i would like to keep the old address (http://www.mydomine.com/corp/blog) for SEO purposes. I added the following configuration tu my .htaccess file.
RewriteCond %{REQUEST_URI} ^/corp/blog
RewriteRule ^(.*)$ http://blog.mydomine.com/$1 [L]
I would like to know if I can tell apache not to change the browser address after redirect the request. I know that I could do a 301 redirection but i would prefer to keep the old address.
Any ideas? Thanks in advance!! :)
Use the P flag
http://httpd.apache.org/docs/current/rewrite/flags.html#flag_p
RewriteRule ^(.*)$ http://blog.mydomine.com/$1 [P]
You could try a reverse proxy...
ProxyRequests Off
ProxyPreserveHost on
ProxyPass /corp/blog http://blog.mydomine.com/
ProxyPassReverse /corp/blog http://blog.mydomine.com/
ProxyPassReverseCookiePath /corp/blog /
This requires mod_proxy be installed and enabled.
Note that this will only work in the following contexts per the apache doc: server config, virtual host, directory - this means that putting it in a htaccess file won't work.
What you're wanting isn't really possible. It's not Apache that's displaying the address, it's the web browser, and there's no way (thankfully) to tell a web browser "go to site A, but tell the user it's site B."
You could fake this behavior using a frame page on your main site, but since you're wanting this for SEO I don't think that would help.

htaccess redirect a subdomain of a wordpress network site to a page

I am currently running a subdomain WordPress Network at domain1.org. One of the subdomain sites is domain mapped to domain2.org. I am trying to add a subdomain to domain2.org that will appear as sample.domain2.org. The problem is that the domain2 is pointed to domain1. We don't use wildcards, we manually edit the DNS for each subdomain site (server admin rule). Tried a redirect rule like Redirect 301 http://friend.episode13.org/ http://episode13.org/friend/
Thoughts?
You need to setup a vhost for friend.episode13.org, and in that vhost redirect to http://episode13.org/friend/:
Redirect 301 / http://episode13.org/friend/
Otherwise, you can try using mod_rewrite and in the vhost (or htaccess file in the document root) where the friend.episode13.org subdomain points to, add:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^friend\.episode13\.org$ [NC]
RewriteRule ^/?(.*)$ http://episode13.org/friend/$1 [L,R=301]

What is the canonical url of my website with www or without?

For my site: http://www.indiacustomercare.com which one is the canonical url with www or without www?
I've not changed any settings.
I remember that I changed this to www. in one for my previous drupal-6 website but I've forgotten it now(I did not change .htaccess).
So if I access my site as http://indiacustomercare.com then all pages seem to be without www ( except for those in the footer which are hardcoded with www...)
Similarly for when I access my site as http://www.indiacustomercare.com all web pages seem to have www prefix.
So what is my site's default www or without www?
Yes, in Drupal .htaccess there are pre-defined settings for this. Go to line 90-97, choose which domain you want to use (with or without www), uncomment the appropriate lines and add there your domain.
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
This one redirects from example.com to www.example.com.
There is also the opposite direction below.
You choose, but it's considered best practice to go with either one or the other, and not leave both available. If you set up a 301 Redirect, it is nicer for search engines.

Resources