如何在同一子域上启用 WordPress 安装和 Mediawiki 安装?
How to enable a WordPress installation and a Mediawiki installation on the same subdomain?
我有一个在其根目录下安装了 WordPress 的子域(例如 https://sub.domain.com
)。这将打开 WordPress 主页。
然后我在名为 w
的目录中安装了一个 Mediawiki 安装,并使用 ShortURL 方法重命名它 specified here in this Mediawiki documentation 并添加了必要的 .htaccess
调整以使 Mediawiki 安装使用这个url 结构:https://sub.domain.com/wiki
.
然后我在另一个名为 typ
的文件夹中添加了另一个 Mediawiki 安装,并按照上面详述的相同步骤进行操作。
我想为不同的目的安装 2 个 Mediawiki。它们彼此没有链接。
但是,在安装 Mediawiki 之后,WordPress 接管了工作,当我尝试访问 /wiki
url 时,我从 WordPress 得到了一个 404 not found
。
这是我的 .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]
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?typing(/.*)?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width= [L,QSA,B]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width=&archived=1 [L,QSA,B]
</IfModule>
# END WordPress
# php -- BEGIN cPanel-generated handler, do not edit
# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.
# Do not edit. This next line is to support the cPanel php wrapper (php_cli).
# AddType application/x-httpd-ea-php70 .php .phtml
# php -- END cPanel-generated handler, do not edit
显示 Mediawiki 安装的唯一方法是注释掉 WordPress 行,如下所示:
#RewriteBase /
#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
我的问题是:有没有办法让所有安装同时工作?所以 https://sub.domain.com
打开 WordPress 安装,https://sub.domain.com/wiki
和 https://sub.domain.com/typing
打开 MEdiawiki 安装?
我找到的唯一解决方案是将 Mediawiki 行移动到 .htaccess
文件中,删除重复项。
这是有效的最终代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?typing(/.*)?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width= [L,QSA,B]
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width=&archived=1 [L,QSA,B]
RewriteRule ^/?typ/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/typ/thumb.php?f=&width= [L,QSA,B]
RewriteRule ^/?typ/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/typ/thumb.php?f=&width=&archived=1 [L,QSA,B]
</IfModule>
我有一个在其根目录下安装了 WordPress 的子域(例如 https://sub.domain.com
)。这将打开 WordPress 主页。
然后我在名为 w
的目录中安装了一个 Mediawiki 安装,并使用 ShortURL 方法重命名它 specified here in this Mediawiki documentation 并添加了必要的 .htaccess
调整以使 Mediawiki 安装使用这个url 结构:https://sub.domain.com/wiki
.
然后我在另一个名为 typ
的文件夹中添加了另一个 Mediawiki 安装,并按照上面详述的相同步骤进行操作。
我想为不同的目的安装 2 个 Mediawiki。它们彼此没有链接。
但是,在安装 Mediawiki 之后,WordPress 接管了工作,当我尝试访问 /wiki
url 时,我从 WordPress 得到了一个 404 not found
。
这是我的 .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]
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?typing(/.*)?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width= [L,QSA,B]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width=&archived=1 [L,QSA,B]
</IfModule>
# END WordPress
# php -- BEGIN cPanel-generated handler, do not edit
# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.
# Do not edit. This next line is to support the cPanel php wrapper (php_cli).
# AddType application/x-httpd-ea-php70 .php .phtml
# php -- END cPanel-generated handler, do not edit
显示 Mediawiki 安装的唯一方法是注释掉 WordPress 行,如下所示:
#RewriteBase /
#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
我的问题是:有没有办法让所有安装同时工作?所以 https://sub.domain.com
打开 WordPress 安装,https://sub.domain.com/wiki
和 https://sub.domain.com/typing
打开 MEdiawiki 安装?
我找到的唯一解决方案是将 Mediawiki 行移动到 .htaccess
文件中,删除重复项。
这是有效的最终代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?typing(/.*)?$ %{DOCUMENT_ROOT}/typ/index.php [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width= [L,QSA,B]
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=&width=&archived=1 [L,QSA,B]
RewriteRule ^/?typ/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/typ/thumb.php?f=&width= [L,QSA,B]
RewriteRule ^/?typ/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/typ/thumb.php?f=&width=&archived=1 [L,QSA,B]
</IfModule>