Currently I am setting up a WordPress Multisite. Every customer will have their own subdomain.
So in this example our site is called: www.example-site.de. One customer will have his own domain called "www.customerxy.example-site.de"
Unfortunately, sometimes the subdomains redirect to the main domain. If I type "https://customerxy.example-site.de" I was not able to reproduce the problem. Just when I typed "customerxy.example-site.de". I do not know if this has anything to do with it, but this was something I noticed.
I already wrote that it could be, because subdomain and main domain are pointing on the same folder. The .htaccess file shows the following:
"
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://customerxy.example-site.de/$1 [R=301,L]
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress
"
If some1 has any idea how to fix this that sometimes the subdomains redirect to the main domain, I'd be so glad. Thank you for every help in advance!
Best regards
Benjamin
Related
I have a CodeIgniter website in my server root directory. This website does have a lot of pages approx ~2M to ~2.5M pages with lots of other functionality. However; now I have developed one WordPress multisite for my home page and another 12 landing page. I've used WPML for the same. now I need to accomplish the following structure,
domain.com -> My CodeIgniter website.
lp.domain.com -> WordPress multisite main site.
ex1.lp.domain.com to ex11.lp.domain.com -> for my 12 landing page.
Now, When I am migrating the WordPress installation to the subdomain then it's getting in a redirection loop.
Can anyone help me with a solution that I can do for the same?
Appreciate your help in advance
use a rewrite in the CI mainsite (after CI's rewrite script),
RewriteEngine On
RewriteCond %{HTTP_HOST} (.*)\.domain\.tld$
RewriteCond %{HTTP_HOST} domain\.tld$
RewriteCond %{HTTP_HOST} ^domain\.tld[NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld$
RewriteCond %{HTTP_HOST} !^(lp|subdom1|sub2dom2)\.domain\.tld$ [NC]
then a permanent redirect to,
RewriteRule ^(.*) https://www.domain.tld/%1/$1 [L,R=302]
and then in WP,
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
the live example is here with CI, https:// www.gsunitedtechnologies .com (subdomain : https:// blog.gsunitedtechnologies .com and the same host with a multisite wp network on https:// beatthedrumfor. com (subdomain: https:// in.beatthedrumfor. com)
A friend of mine asked for help about his wordpress site. He did his work under sub.domain.com and now he'd like to have domain.com redirected to it, if possible without showing sub in the url bar
This is his domain root .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Following some resources I found, I inserted these two lines after the RewriteEngine On:
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R]
But it doesn't seem to work, it should be so simple but I am doing clearly something wrong...
I tried also commenting the rest, it didn't work
I am not an Apache expert at all, what's the problem?
To redirect example.com/ to sub.example.com/ ,you can use the following :
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^$ http://sub.domain.com/$1 [L,R]
^$ matches the root / of example.com ,if you want to redirect everything to subdomain ,change the pattern to ^(.*)$ .
I'm new to VPS servers and just setting up a test environment to find my way around. I have WHM installed and have just created a new account with cpanel, I want to be able to visit the temp url, i.e. http://IP/~user however, when I visit, my browser adds a www. to the front (http://www.IP/~user/) which brings up a "page cannot be found" error.
Can anyone explain to me what is going on here and how I rectify it
Thanks
UPDATE: Here is my htaccess in the root of my public_html file (it's just a standard wordpress multisite htaccess)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
You have to enable mod_userdir from WHM backend
Ok, here is the situation i can´t solve:
I have a WP multisite running on a server with 3 domains and 3 sites, and in that server i also have a subdomain running it´s own WP.
So, let´s say i have this MU sites:
site_1.com
site_2.com
site_3.com
And also i have this subdomain:
blog.site_1.com
The thing is if i go to this url: "site_2.com/blog" it show me the page using a 404 template with the subdomain theme style. Yeah!!
So, trying to access "site_2.com/blog", give me 404 using a theme that is in use on a subdomain named "blog" that is live over: blog.site_1.com.
My MU htaccess has this:
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
RewriteCond %{HTTP_HOST} ^blog.site_1.com [OR]
RewriteCond %{HTTP_HOST} ^www.blog.site_1.com$
RewriteRule ^(.*)$ http://site_1.com [R=301,L]
Last 3 lines are obviusly required in order to have a diferent WP instalation running on that subdomain that is actualy the "blog" folder on my public_html.
Also that "blog/" folder (where is installed the site under blog.site_1.com) has this default wp htaccess code:
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Maybe thats the problem, i have for one part a multisite running with 3 domains maping into the same server, but also on another part a subdomain running it´s own wp instalation and, badly, in this case i builded a page named "blog" that conflict with the "blog" folder that is actualy another site ?¿?¿?¿ jejej, it´s crazy, and at this point this is personal :) i need to know why i can´t make this working ok.
Any idea on how i can solve this thing? Thanks
On my server I've got a single WordPress installation for my own company website.
Besides that, I would like to create a demo area for clients.
At the moment I've got the following setup and folders:
www.domain.com - Single WordPress installation for company website
www.domain.com/demo/ - WordPress Multisite
At the moment all the clients websites have the following domain structure:
www.domain.com/demo/client1, www.domain.com/demo/client2, etc.
Instead of those long urls, I would like a subdomain:
demo.domain.com/client1, demo.domain.com/client2, etc.
WordPress Multisite standard generates the following .htaccess:
RewriteEngine On
RewriteBase /demo/
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
From other topics at stackoverflow I've found the following:
RewriteRule ^demo/(.*) demo.domain.com/$2/
But unfortunately this doesn't work. Anybody who can help me?
Thanks in advance!
Keep the multisite .htaccess where it is and put this in the .htaccess in the root of your web directory:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^demo
RewriteRule ^(.*)$ http://www.domain.com/demo/$1