.htaccess rewrite WordPress Multisite - wordpress

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

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

cpanel can't visit temp url - redirects to http://www.ip/~user/

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

Wordpress directory conflict: Need advice on htaccess paths

I am moving a website to Wordpress, and using the Multiblog functionality. I'm not a htaccess expert by any means, but I do manage to use it regularly. So I'm reaching out here for some expert advice.
The website, www.blather.ie will use the same path for the sub-blogs as the old website. I need to keep legacy folders - like www.blather.ie/zeitgeist and some of the old content while publishing a Wordpress blog to the same path. I realised when I tried to this that 403 error would occur. So I found a workaround here and here.
Adding lines to my htaccess as described in those pages to my exist file didn't work. When I cleared out the htaccess file and started from scratch, I no longer got the 403 error - the content appeared, but without any themes/stylesheets. I checked the source, and saw that it was trying to pull the info from www.blather.ie/zeitgeist/wp-content... which doesn't exist - it needs to pull it from www.blather.ie/wp-content/...
Also, this 'fix' also started creating loops in the Admin back end. Not sure why.
So, here's my original htaccess file:
# BEGIN WordPress
Options +FollowSymLinks
<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).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Here's the same htaccess with the recommended fix for the directory conflict problem, but which still causes the 403 error.
# BEGIN WordPress
Options +FollowSymLinks
<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]
# Fix 403 errors on existing directories; WordPress overrides.
RewriteCond %{REQUEST_URI} ^/(zeitgeist)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Here's a "clean" htaccess taken from the 1st recommended website - it cures the 403, but breaks paths, points to the wrong stylesheet location and causes redirect loops and 403s in the backend instead:
# 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]
# Fix 403 errors on existing directories; WordPress overrides.
RewriteCond %{REQUEST_URI} ^/(zeitgeist)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
So - my question - where am I going wrong with paths, and causing these damn feedback loops?
Thanks in advance!
Try this? Use the basic WP .htaccess, don't get fancy at all and instead drop a tiny .htaccess in each legacy folder (these are dirs right?) that disables rewrite in the folder.
This method worked for me as I needed to provide access to legacy folders as well. There are some options you may need to hit with casual variations for environments. There are a few ways to do this such as disable rewrite, allow dir access, show details, etc so I can't include a snippet for you at this juncture.

Wordpress subdomain and multisite

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

Why does the URL include /blog/ on one of my Multisite WP sites and not the other?

Can some one tell me why I have one Multisite that includes a /blog/ in the url and the other one doesn't?
EG:
http://site1.com/blog/article
http://site2.com/article
How can I change this on a site by site basis?
And when I change it how should a redirect the current URLs to the new location.
What is the code for .htaccess file?
Thanks! :)
if you used the subdirectory install of WPMU the .htaccess must like the below
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [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]

Resources