我正在使用apache2和mod-proxy将wordpress博客整合到我的TLD的子目录中。
Apach2主站点的虚拟主机与代理:
<VirtualHost *:80> ServerName example.com ... # Rewrite rule to add missing slashes RewriteRule ^/blog$ /blog/ [R=301] RewriteRule ^/other-blog$ /other-blog/ [R=301] <Proxy *> Order deny,allow Allow from all </Proxy> ProxyRequests off ProxyPass /blog/ http://blog1.localhost/ ProxyPassReverse /blog/ http://blog1.localhost/ ProxyPass /other-blog/ http://blog2.localhost/ ProxyPassReverse /other-blog/ http://blog2.localhost/ ... </VirtualHost>
用于博客的Apach2虚拟主机:
<VirtualHost *:80> ServerName blog1.localhost DocumentRoot /var/www/blog1/ <Directory /> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost>
Linux主机文件添加行:
127.0.0.1 blog1.localhost localhost.localdomain 127.0.0.1 blog2.localhost localhost.localdomain
WordPress的:设置>常规设置:
.htaccess文件:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
这个设置一般工作正常。 不幸的是,WordPress的后端通过剥离URL中的子文件夹在某些部分存在问题,导致保存设置或加载图片的问题。 例如。:
要么
我到目前为止所尝试的是:
目前为止没有任何工作,或使情况变得更糟。
如果有人有如何解决这个问题的想法,我将非常感激这一点。
*)编辑:我已经在这里试过了:
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/blog'); define('WP_HOME', 'http://example.com/blog'); define('WP_SITEURL', 'http://example.com' . $_SERVER['SERVER_NAME'] . '/blog'); define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/blog'); define('WP_SITEURL', 'http://example.com/blog/');
绝对的(和错误的)path是由WordPress生成的内容 – 无法用Apache重写(Apache如何知道客户端要求/wp-content时意味着哪个博客)。
修改WordPressconfiguration中的站点URL是正确的path。
对于blog1实例:
define('WP_SITEURL', 'http://example.com/blog');
对于blog2实例:
define('WP_SITEURL', 'http://example.com/other-blog');
你尝试了什么,你看到了什么行为?
你可能需要将你的wordpress安装到一个子目录来解决这个问题。 一旦完成,编辑你的重写规则,类似于这样的:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog1/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog1/index.php [L] </IfModule>