Wordpress subdomain and multisite - wordpress

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

Related

Subdomain redirecting to domain

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

Permalinks issue with Wordpress in subfolder and domain redirect

I installed a Wordpress website on an hosting space where there was already an active website. I didn't want to delete that so I put Wordpress in its own directory, having: http://domain.com/wordpress
In the wp-config.php file I set:
define('WP_HOME', 'http://domain.com/wordpress/');
define('WP_SITEURL', 'http://domain.com/wordpress/');
Then, I created an .htaccess file in the root and one in the wordpress folder. They respectively contain:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ wordpress [L]
and
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
This way, when I go to http://domain.com/ I get redirected to http://domain.com/wordpress and everything on the website works fine. What I want, though, is to have the url displaying just http://domain.com, without the "wordpress" part. Is something I can achieve just with the .htaccess?
Another issue I'm facing is that there is a redirect domain set. There is this http://otherdomain.com pointing to http://domain.com. This other domain should actually be the main one. Right now, when I access http://otherdomain.com the website is displayed correctly; the links are working, but the url doesn't change accordingly: it always shows http://otherdomain.com, no matter what.
What I tried so far is to search and replace all the entries in the database, substituting the domains and modify other options accordingly. Doing this the website is shown without css, no images and no links working.
To fix issue with subfolder try to replace
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
with
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteRule ^(/)?$ wordpress/index.php
Don't forget to replace yourdomain.com with exact domain name.
Also, please revert database changes back, as right now WordPress is trying to find files in the root dir.
If this won't work, you might have such redirect option in your hosting account panel.

Wordpress redirect to a subdirectory with permalinks

I have a wordpress blog in a subdirectory at domain.com/blog. I want to access it from the main domain, without anyone seeing it is in a subdirectory. I've managed to do a transparent redirect from the domain to the directory using some help, but I can't seem to get the pretty permalinks to work. This is what I use for the redirection:
RewriteEngine on
# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Only apply to URLs that aren't already under /blog.
RewriteCond %{REQUEST_URI} !^/blog/
# Rewrite all those to insert /blog.
RewriteRule ^(.*)$ /blog/$1
# Redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ blog/ [L]
And this is what I would use for permalinks if the blog wasn't in a subdirectory and there wouldn't be any redirects:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
As far as I've tried combining the two rulesets, I either get an infinite loop or a not found from wordpress.
So how can these two rulesets be merged, so that the blog could be accessed by redirecting to a subdirectory and friendly urls could be used?
Thanks
perma link is just a setting in your admin side
go to setting and look for that and change the website url
not the wordpress url!!

.htaccess rewrite WordPress Multisite

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

.htaccess file problems

So I have a Joomla instance which is sitting in my ROOT directory. I have a Wordpress Multi-site installation sitting in the subdirectory /blog.
It seems like the server is having a hard time finding or getting sites in the /blog directory. Seems like it gets to the main /blog page fine but if I want to go to /blog/{sitename}, sitename being an instance of the Wordpress Mulitsite, it has a hard time getting there. Probably complicating matters is that I have Fancy URLs on both the Joomla instance as well as the Wordpress Multisite instance.
Both .htaccess files for Joomla and Wordpress Multisite are from stock installs of their respective applications (I'm 99% sure).
I'm going to post them here and see if anyone can see possible conflicts in the .htaccess
Joomla .htaccess with core SEF
version $Id: htaccess.txt 21064 2011-04-03 22:12:19Z dextercowley $
RewriteEngine On
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
END Joomla .htaccess
Now I have added this to the Joomla .htaccess file in hopes that it would not use SEF on the /blog folder but it doesn't seem to work. I am trying to exclude the blog directory from the top level .htaccess and just let the /blog .htaccess take over control of that subdirectory.
#RewriteCond %{REQUEST_URI} ^/blog/.*$
#RewriteRule ^.*$ - [L]
And here is my Wordpress .htaccess
RewriteEngine On
RewriteBase /blog/
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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Everything on the top level domain (Joomla) runs very fast when pages are requested.
The server eventually finds the /blog directory but it takes more time than it should. The really big problem is that when i go to one of the blog sites (/blog/sitename) it can take upwards of 8-10 seconds. And then once the page loads and I go to another page on that /blog/sitename like "About" it can take about the same amount of time.
Overall very frustrating. Any help is appreciated. I've been googling for awhile and have not found much help besides
#RewriteCond %{REQUEST_URI} ^/blog/.*$
#RewriteRule ^.*$ - [L]
And it has not helped the problem.
It seems like all the sites in the /blog directory are very slow to get to. I have about 6 in there and they are all very slow loading.
Well, I'm not sure if you're developing locally but one thing you could try would be to place all the Joomla files in their own directory and use .htaccess to resolve the site correctly - then you shouldn't have the Joomla .htaccess affecting your /blog directory.
Just a consideration. I'm not sure that it would resolve the issue entirely but at least then you could separate out the issue of 'is the Joomla .htaccess conflicting with the Wordpress .htacceess and causing a slowdown'.

Resources