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

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]

Related

How to redirect multiple domains in bitnami wordpress config

I've searched and haven't been able to find an answer to this. A lot of the information I've found appears to be out of date.
I have a Bitnami wordpress installation, running Apache on a lightsail instance.
I have multiple different domains resolving to the server. At the moment, each domain displays in the browser if you use it
eg
website-address.com - displays in browser
website-address.org - displays in browser
etc
I just want website-address.com to display in the browser with any other domains redirecting to that.
It seems that 301 redirects are not managed by htaccess files any more. As far as I can tell, this should be configured using the virtual hosts configuration in the bitnami.conf file
I currently have two vhosts in that file, one for port 80 and one for 443
There are a number of rewrite conditions in there, rewriting things like www to non www and http to https, all of which work.
I have configured the ServerName to the domain that I want in both virtual hosts and the ServerAlias to match all of the other urls
I have also tried adding:
RewriteCond %{HTTP_HOST} !^{SERVER_NAME}
RewriteRule ^(.*)$ https://{SERVER_NAME}/$1 [R,L]
but the alternate domains are still not redirecting.
Is there something else I need to add? Do I need to configure a vhost for each of the alternate domains and if so, do I just do it for 443 or do I need to do it for port 80 as well?

Why did my word-press site is showing not secure

I have a new website but it has some SSL issue.
Issue is that when i type my website URL without https like only (example.com) in address bar it becomes not secure
and when i type https with it like (https://example.com) my site show secure.
I have installed the SSL certificate with my cPanel "Let Encrypt SSL" option.
And i have update my urls from http to https in my worpress Settings > General.
Help me with this I want to type my url in address bar without https (example.com) like othere website we usually surf on internet and want it to automatically detect that it is a secure website.
I'm assuming you've already acquired an SSL certificate for your site.
What you want to do is redirect HTTP to HTTPS via your .htaccess file. A quick search will tell you how to do that, it is something like:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.example/$1 [R,L]
Another easy solution is to redirect via your Apache configuration. Navigate to /etc/apache2/sites-available/ and edit your site's config file. Add the following lines:
<VirtualHost *:80>
ServerName yourdomain.com
Redirect permanent / https://yourdomain.example/
</VirtualHost>

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 load wordpress by two URL

I need to wordpress from 2 url, my main wp already run in subdomain wp.domain.com but I can't access from domain.com/wp, I try some change in database and .httaccess file, but I can't run it with 2 url
I need can access both of them :
wp.domain.com
domain.com/wp
WordPress doesn't really support this setup. All posts have saved their URL in the database, if you display the site on the secondary URL all links will still point to the primary URL.
Additionally, displaying the same content on different domains (what this is) is usually penalized by search engines, which is something you usually want to avoid.
You can achieve this by configuring the Apache with mod_proxy and mod_proxy_html to proxy all requests on one domain to the other, rewriting the URLs in the process.
The Apache config for this looks like this:
ProxyPass /wp/ http://wp.domain.com/
ProxyPassReverse /wp/ http://wp.domain.com/
# to rewrite the URLs in the HTML
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap http://wp.domain.com https://domain.com/wp
But I'd recommend to stick to a single URL and configure Apache to redirect all requests on the secondary URL to the primary.
You can do that with a single line in a .htaccess:
RewriteRule ^(.*)$ http://wp.domain.com/$1 [R=301,L]

Multiple domains in 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).

Resources