帮助:MediaWiki 安装:修订间差异
来自陋室
更多操作
删除的内容 添加的内容
→MediaWiki 维护: 更新脚本 |
小 →Apache 与 HTTPS: 更新 |
||
| 第204行: | 第204行: | ||
将以下规则放入 <code>/www/wwwroot/mediawiki-1.44.0/.htaccess</code> 文件,以实现短链接(如 <code>/w/PageTitle</code>)和 HTTPS 强制跳转。 |
将以下规则放入 <code>/www/wwwroot/mediawiki-1.44.0/.htaccess</code> 文件,以实现短链接(如 <code>/w/PageTitle</code>)和 HTTPS 强制跳转。 |
||
<syntaxhighlight lang="apache"> |
<syntaxhighlight lang="apache"> |
||
# 强制 HTTPS(优先放最上面) |
|||
| ⚫ | |||
# 强制 HTTPS |
|||
RewriteCond %{HTTPS} off |
RewriteCond %{HTTPS} off |
||
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
||
# 启用 URL 重写 |
|||
# MediaWiki 短链接规则 |
|||
| ⚫ | |||
# 排除静态资源和 API 不进行重写 |
|||
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|less)$ [NC] |
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|less)$ [NC] |
||
RewriteCond %{REQUEST_URI} !^/load |
RewriteCond %{REQUEST_URI} !^/load.php [NC] |
||
RewriteCond %{REQUEST_URI} !^/api |
RewriteCond %{REQUEST_URI} !^/api.php [NC] |
||
RewriteCond %{REQUEST_URI} !^/images/ [NC] |
|||
# 重写 wiki 页面路径(建议使用 /w/ 而非 /w/ ) |
|||
RewriteRule ^w/(.*)$ /index.php?title=$1 [L,QSA] |
RewriteRule ^w/(.*)$ /index.php?title=$1 [L,QSA] |
||
# 默认重写(必须放最后) |
|||
# 前端控制器模式,将所有其他请求路由到 index.php |
|||
RewriteCond %{REQUEST_FILENAME} !-f |
RewriteCond %{REQUEST_FILENAME} !-f |
||
RewriteCond %{REQUEST_FILENAME} !-d |
RewriteCond %{REQUEST_FILENAME} !-d |
||
RewriteRule ^(.*)$ /index.php [L,QSA] |
RewriteRule ^(.*)$ /index.php [L,QSA] |
||
</syntaxhighlight> |
</syntaxhighlight> |
||