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.
Related
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?
TL;DR: I want to redirect https to http on all pages except for admin/login, where I want the exact opposite to happen. I also want www redirected to bare domain name. (UPDATE: Check Update 3 for the answer)
As is probably clear from the title, I have a Wordpress blog hosted on OpenShift for free. I have a custom domain bought from GoDaddy. I'm using cloudflare so I can have free SSL.
Here's my configuration:
CloudFlare DNS:
CloudFlare Page Rules:
This is what worked best. I actually wanted to have this rule:
*ghostlessmachine.com/* -> https://ghostlessmachine.com/$1
But I ran into even more problems like that, even though it seems to be pretty much what I'm supposed to do according to this CloudFlare article. Actually, initially I wanted to only force SSL in admin pages, but I didn't even know how to attempt that. I thought of using two page rules, like this:
*ghostlessmachine.com/* -> http://ghostlessmachine.com/$2
*ghostlessmachine.com/wp-* -> http://ghostlessmachine.com/$2
But I had no luck.
Here's my OpenShift configuration:
When I write ghostlessmachine.com in my address bar, it correctly takes me to https:.... I have shared a link, however (https://ghost...), and one person has reported not being able to access it. I couldn't reproduce locally.
When I try www.ghost..., I get:
This webpage has a redirect loop
ERR_TOO_MANY_REDIRECTS
Does anybody have any idea what I'm doing wrong? I've lost track of how many different configurations I've tried, but nothing seems to work.
Thanks!
UPDATE
OK, so following the advice in the comment I managed to get the situation a bit better. Still it's counter intuitive for me how the article I initially linked to just didn't get the job done while the other SO question did. So here's what I've changed:
Deleted the www.ghost... alias from OpenShift.
Changed CloudFlare's CNAME record from www -> blabla.rhcloud.com to www -> ghostlessmachine.com
Created this Page Rule: www.ghostlessmachine.com/* -> http://ghostlessmachine.com/$1
Now both ghost... and www.ghost... work and take me to http://ghost.... However, if I type https://ghost..., it also works without redirecting me to simple http. This is a problem.
I tried using this Page Rule instead:
ghostlessmachine.com/ -> http://ghostlessmachine.com/$2
So that I got https://, http://www, www, everything redirected to http://ghost..., but it doesn't work. I can't access my blog anymore and whatever address I try I get ERR_TOO_MANY_REDIRECTS.
UPDATE 2
Here's my full setup after all suggestions:
htaccess:
wp-config.php:
CloufFlare:
Result:
https -> http on non-admin/login pages: WORKING ✓
Trying to access admin/login pages: ERR_TOO_MANY_REDIRECTS
Update 3
This did the trick:
I still don't understand why this works and the rest doesn't though. This was basically a series of rather blind trial and error with some input from Allen here and Simon in the CloudFlare support page. In any case, all my requirements are respected now, thanks!
make sure following in your wp-config.php file:
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
look over here: Force non-WWW but force https across all of wordpress & the entire domain
for redirect everything else to non-https, you can add following into your root .htaccess file, before the wordpress rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/wp-admin.*
RewriteCond %{REQUEST_URI} !^/wp-login.*
RewriteCond %{HTTP_REFERER} !^https://.*
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Update:
CloudFlare's Page rule has following "Page rule priority is determined by their position in the list. If multiple rules match a URL, rules at the top take higher priority. "
let's see what happens before:
request to https://www.ghostlessmachine.com/wp-admin hit the first
rule, match found, then it goes to
http://www.ghostlessmachine.com/wp-admin!
now here comes http://www.ghostlessmachine.com/wp-admin, first rule,
no rewrite, goes down to 3rd rule, oops, it needs goto
https://www.ghostlessmachine.com/wp-admin!
this is how the loop comes
I need some help on the htaccess subdomain to be pointed to specific file in a folder for a wordpress site.
Currently I have this in my .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$
RewriteCond %{REQUEST_URI} !^/subdomain/
RewriteRule (.*) /subdomain/$1
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule ^subdomain/(.*)$ http://subdomain.domain.com/$1
When the user enters subdomain.domain.com it will access the domain.com/subdomain folder and when it enter domain.com/subdomain it will redirect to subdomain.domain.com. (this is exactly what i want to happen)
Problem is inside the wordpress of the subdomain because it still referrer to the main domain (i.e. the images is still domain.com/wp-content/uploads/... instead of subdomain.domain.com/wp-content/uploads/... or at least domain.com/subdomain/wp-content/uploads/...).
How do I make the subdomain access the its folder in .htaccess?
Been doing this for days now. please help. thanks!
Open your WordPress installation's general settings.
Change your Site Address (URL) to http://subdomain.domain.com/. This will fix the links generated on all the blog pages to use the sub-domain instead of the main one.
I'm trying to install Wordpress in a subdomain on a shared hosting.
Me and my father have a domain together - artazov.cz. I have my own subdomain michal.artazov.cz. I want to go one level deeper and make a blog in the subdomain of the subdomain - blog.michal.artazov.cz. Now, it shouldn't matter, how many levels deep I go if I match it directly with regular expression in .htaccess. So that's what I did:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/?subdom/michal/subdom/blog/
RewriteCond %{HTTP_HOST} ^(www.)?blog\.michal\.artazov\.cz [NC]
RewriteRule ^(.*)$ http://artazov.cz/subdom/michal/subdom/blog/$1 [L,P]
There are 2 problems with this.
Wordpress by default is set up in a way, that in General settings, "Site Address (URL)" is set to http://artazov/subdom/michal/subdom/blog. Therefore every link on the website, including permalinks to articles, have this signature, instead of http://blog.michal.artazov.cz.
When I change that setting to http://blog.michal.artazov.cz, the website returns 404 Not Found and I have to go to database and change it back.
Is there some way to set it up so it works and runs in the desired subdomain, including all the links, generated by Wordpress itself? Thanks
Perhaps you have attempted likely to: Configurations in Wordpress-Admin >> Media Configurations Then try altering both:
I think you may should try changing permalinks:
http://codex.wordpress.org/Using_Permalinks
Is there a way to map a domain name to a WordPress page?
For example, if I have mydomain.com/about/bio and mydomain.com/about/resume, could I map anotherdomain.com to the about page so I could use anotherdomain.com/bio and anotherdomain.com/resume?
Additionally, could I do it with a subdomain too?
Using the same example above, could I map about.anotherdomain.com to mydomain.com/about?
With WordPress, these aren't physical folders. They're pretty permalinks, so I'm having trouble figuring out how to make this work.
We have a Plesk control panel.
Thanks for any insight you can provide!
Edit:
The domains that I'd like to map to different parts of the URL may be registered from various providers.
You can achive this using the .htaccess file....
Just point the A record of your domain names to your domain. Now do the following...
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com
Rewriterule ^(.*)$ http://mydomain.com/about/bio [L]
RewriteCond %{HTTP_HOST} ^(www.)?myresumedomain.com
Rewriterule ^(.*)$ http://myresumedomain.com/about/resume [L]
RewriteCond %{HTTP_HOST} ^(www.)?anotherdomain.com
Rewriterule ^(.*)$ http://anotherdomain.com/bio [L]
Two possibilities you can explore:
A/ Using the plesk (or other registrar), you could try a wild-card redirect such as:
anotherdomain.com -> mydomain.com/about // with "wildcard" set to "yes".
B/ If that fails, you can create a simple redirect (anotherdomain.com -> mydomain.com) and then in WordPress (assuming it's living at mydomain.com), manually redirect individual URLs using the Redirection Plugin.
You would create individual rules like:
anotherdomain.com/bio -> mydomain.com/about/bio
C/ Finally, WordPress has become so good at redirecting broken links that you might be able to get away with simply redirecting the anotherdomain.com to mydomain.com and seeing if wordpress serves the correct page when an approximate URL is entered.
anotherdomain.com -> mydomain.com // this is the redirect you create
when people type anotherdomain.com/bio, WP might serve mydomain.com/about/bio auto-magically
Good luck!
if was me, I would do by 2 ways:
Domain forward domain1 -> domain2/about-page
Create a index.html and create a sub-folder on domain1 (ex: domain1.com/about) then linked to it. - Index.html will use iframe to call domain2/about.