Two websites, both WordPress installations.
Old Website is hosted with provider A with their real domain - website.com.au (not real address obviously)
New Website is hosted with provider B and has temporary domain - lotsofcrazynumbers.com.au
In the process of transferring domain over to provider B but they can't wait for that to happen and have asked me to fwd their real domain over to New Website.
So I edited .htaccess in Old Website's admin area to fwd to New Website's temporary domain but of course the temporary domain is displaying, which will freak out their customers.
I used the following in the .htaccess
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ "lotsofcrazynumbers.com.au" [R=301,L]
I know that I probably haven't set this up right but domains and DNS is not really my thing. Is there anyway that I can mask the temporary domain so that it looks like their normal domain until the domain transfer has been finalised?
Any help would be appreciated..
mod_rewrite's [P]roxy option might work:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^(.*)$ "http://lotsofcrazynumbers.com.au$1" [P,L]
Set the above in the .htaccess file of Old Website, and it should proxy any requests to New Website without change the URL in the browser.
Make sure to test properly though. :-)
Related
I have created a subfolder in my webserver and installed wordpress there, it's working ok. And now i have created several subdomains. I need to show pages made in the wordpress installation in those subdomains but without changing the addess shown in the web browser address bar.
Options +FollowSymLinks
RewriteEngine on
RewriteOptions inherit
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/WPweb/index.php/pagetobeshown [R=301,NC,L,QSA]
with this i am being redirected and content is shown ok, but the address bar is changed.
is it possible to fix this so that address is not changed?
thanks in advance
To do this in .htaccess you would need to configure your server as a reverse proxy and proxy the request from the subdomain to the URL on the main domain. WordPress will then see this as a request for the main domain.
However, this does require some configuration in your server config to ensure the appropriate modules are loaded (mod_proxy, mod_proxy_http, etc.) and optionally to set ProxyPassReverse if WordPress should issue any redirects.
You can then use the P flag with mod_rewrite's RewriteRule to send the request through mod_proxy. For example:
RewriteCond %{HTTP_HOST} ^sub\.example\.com
RewriteRule ^$ https://example.com/WPweb/index.php/pagetobeshown [P]
This sends requests for https://sub.example.com/ only (ie. the document root of the subdomain) to the URL as stated. The NC, QSA and L flags are not required.
If you want to send any URL-path (as implied by your RewriteRule directive) to the URL on the target site then change the RewriteRule pattern from ^$ to ^ (simply remove the $). However, this many-to-one relationship is not necessarily good for SEO.
You will still need to modify the rel="canonical" link elements in the page to the appropriate URL in WordPress itself.
However, I'm sure there is a better, more WordPress-specific way to solve this. But WordPress would need to be configured to accept requests to the subdomain and the alternative URL-path.
I have a client whose website develops & sells retirement villages in multiple locations, it's a Wordpress Multisite, with the main site being generic and the subsites are all the different locations. Basically we want to have an abbreviated domain for each location for advertising purposes that takes visitors to the correct location subsite, without changing the url, because we don't want to have to purchase SSL for every single domain/subsite.
so basically
locationA.com
when entered in the address bar goes to
https://mainsite.com/locationA
without changing the subsite url in the browser to LocationA.com - I know how to change the subsite domain via the wordpress admin settings but we don't want to change permalinks/urls unless there is absolutely no other way.
All the domains are parked at the mainsite's hosting,
I've tried redirecting via the cPanel Alias settings going to https://mainsite.com/locationA, but it always just takes us to https://mainsite.com/
RewriteCond %{HTTP_HOST} ^locationA\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.locationA\.com$
RewriteRule ^/?$ "https\:\/\/mainsite\.com\/locationA\/" [R=301,L]
I've tried other various .htaccess edits from other forums but they either break the site or just do the same thing as above and takes us to the generic mainsite.
e.g.
RewriteBase /
RewriteCond %{HTTP_HOST} ^locationA\.com$ [NC]
RewriteRule ^(.*)$ https://mainsite.com/locationA/ [L]
I don't really know what I'm doing with these, just trying things until something works.
Any help or insight would be greatly appreciated, thanks!
Nevermind, fixed it myself. The problem was that I added the domains as an 'Alias', redirection via CPanel worked when I added them as 'Addon Domains' instead.
I want to redirect some URLS on the old site to specific destination on the new site and the rest of the URLS to the home page. So far I have tried the following:
Use Redirect 301 /permalink https://newsite.com/permalink1/ for all the links that need to go to a specific page on the new site
For the rest, I added a generic rule
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [NC]
RewriteRule ^(.*)$ https://newsite.com [R=301,L]
but this redirects all the pages to the home page of the new site.
Then I tried to replace point 2 above with RedirectMatch
RedirectMatch 301 .* https://newsite.com
but this tries to find an exact match on the new site. oldsite.com/xyz goes to https://newsite.com/xyz
Also, some of the old site URLs have parameters, oldsite.com/a=?b=123 how can I redirect such parameters to the new site homepage.
This probably is a straight forward approach:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite\.com$
RewriteRule ^/?permalink1old(/.*)$ https://newsite.com/permalink1new$1 [R=301,QSA]
RewriteCond %{HTTP_HOST} ^oldsite\.com$
RewriteRule ^/?permalink2old(/.*)$ https://newsite.com/permalink2new$1 [R=301,QSA]
RewriteCond %{HTTP_HOST} ^oldsite\.com$
RewriteRule ^ https://newsite.com/ [R=301]
So you redirect the old permalinks on the old host name to their new counterpart on the new host name, appending anything that might follow in the path of the initial old permalink and you append the query string to preserve arguments.
If the permalinks never contain anything additional in their paths then you can simplify those redirections, obviously:
RewriteCond %{HTTP_HOST} ^oldsite\.com$
RewriteRule ^/?permalink1old/?$ https://newsite.com/permalink1new [R=301,QSA]
It is a good idea to start out with a 302 temporary redirection and only change that to a 301 permanent redirection later, once you are certain everything is correctly set up. That prevents caching issues while trying things out...
This implementation will work likewise in the http servers host configuration or inside a dynamic configuration file (".htaccess" file). Obviously the rewriting module needs to be loaded inside the http server and enabled in the http host. In case you use a dynamic configuration file you need to take care that it's interpretation is enabled at all in the host configuration and that it is located in the host's DOCUMENT_ROOT folder.
And a general remark: you should always prefer to place such rules in the http servers host configuration instead of using dynamic configuration files (".htaccess"). Those dynamic configuration files add complexity, are often a cause of unexpected behavior, hard to debug and they really slow down the http server. They are only provided as a last option for situations where you do not have access to the real http servers host configuration (read: really cheap service providers) or for applications insisting on writing their own rules (which is an obvious security nightmare).
I have two Wordpress sites, one living in the root directory of my server, one living in a directory. Let's call them:
www.domain.com and www.domain.com/folder/
This worked fine until now, when I needed to change my domain and server. I moved my files from one server to the other, got everything running with the new domain on the new server, and then "parked" the old domain on the new server via cPanel, setting up the following .htaccess code in the root directory to handle traffic to the old domain:
RewriteCond %{HTTP_HOST} ^domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301,NC]
This appears to work perfectly for the "main" wordpress install, BUT, while visiting URLs for the Wordpress site in the subdirectory produce the correct results, they display the OLD url:
So, for example, if I visit:
http://www.domain.com/folder/page/
I see the content for:
http://www.newdomain.com/folder/page/ (eg. all the links etc. are correct)
But the URL still displays as http://www.domain.com/folder/page/
Nothing I do with .htaccess, etc. seems to change this. How can I force http://www.domain.com/folder/page/ to fully redirect to http://www.newdomain.com/folder/page/ not just show the content for it?
I've got a site that's setup as a WordPress network/subsite off primary url.
domain.org/subsite
I'd like to rewrite requests from a seperate DNS name - call it domain2.org - (which I control) to that subsite
domain2.org -> domain.org/subsite
I've seen examples of using .htaccess rewrites to route to subfolder, but can't figure out specifics on how to do this.
Thanks for looking.
put this code in your DOCUMENT_ROOT/.htaccess file of domain2:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.org$ [NC]
RewriteRule ^ http://domain.org/subsite%{REQUEST_URI} [R=301,L,NE]
I had an experience working with wordpress multisite which is hosted at godaddy.
Godaddy has an option for the registered domain say for eg http://domain2.org asked for hosting server point or url. In the url field paste it http://www.domain.org/subsite
So check with your hosting provider.