Open ihorvorotnov opened 9 years ago
That is incorrect. In this particular case WordPress is not being installed in the subdirectory. Only the files are. The installation is referenced to root in terms of the WP setup. The issue you have encountered is probably related to rewrite rules.
@Qoto I wish I was wrong, that would make my life easier as I have several multisite installs. When I first encountered this issue I tested everything (including removing any custom rewrites, resetting and even completely disabling permalinks), asked on StackOverflow etc. It proved I'm right. Do you have a working setup? I would love to see it working.
If I read the docs on Codex correct, the part "WordPress URL contains a path, not just a domain" means exactly what I'm refering to - the path to WordPress dir will be domain.com/wp/
, and domain.com/wp/wp-admin/
for the admin. Check the Codex article linked above.
@ihorvorotnov yes, I have a working setup.
Please note: siteurl and homeurl should be domain.com
, not domain.com/wp/
example .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteCond %{SERVER_PORT} !^443
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
I also run a nginx/hhvm multisite subdomain setup, and it works perfectly, which has the following set up:
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite ^/(wp-.*.php)$ /wp/$1 last;
rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;
location ~* ^.+\.(jpe?g|gif|js|css|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mp3)$ {
expires 30d;
rewrite ^/(wp-(content|admin|includes).*) /wp/$1 break;
}
passing php/hh to hhvm via fast-cgi:
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Hope I'm not misreading your requirement
Am I correct - while you have WordPress installed in /wp/
directory, you manually set both WP_HOME
and WP_SITEURL
constants to root, and then you're telling Apache/Nginx to rewrite all requests to WordPress files prepending them with /wp/
on the fly?
p.s. I'm using Nginx/HHVM with PHP5-FPM fallback.
Yes, exactly. This works with apache, apache and nginx as reverse proxy and nginx/HHVM setups.
Sounds good. Will have a chance to set up a network this week and test it. Will let you know if I'll make it work (hope I do). Thanks for sharing this technique!
Anyway, it's a cool trick, not a plain WP setup. It will not work out of the box. I suppose extending my note with your solution will be useful for future users. There's no other solution in Google's db and on SO. Do you agree?
Agreed. Frankly, I'm not sure why this is not documented here, since without these or similar .htaccess and/or server blocks this set up can not work OOB anyway.
Not an issue actually, just a note about Multisite + WordPress in own directory. I think it should be clearly stated in FAQ section of README. Knowing it before would save me some 2 hours :)
WordPress Multisite works well when WP is installed in it's own directory. However, there's one limitation. As stated on Codex:
You cannot choose Sub-domain Install (for a domain-based network) in the following cases:
So, in practice WP Skeleton (or any other way of using WP in it's own directory) is only compatible with a sub-directory setup of WP Multisite.