Manual talk:Short URL/Apache/zh
Add topicAppearance
Latest comment: 2 months ago by 对此佛具 in topic 关于Apache配置代码更新
关于Apache配置代码更新
[edit]我在查阅此页面时发现该页面的配置已经过时,且其中的配置代码大多已经不可用,在此处贴上我自动的一些配置,用以抛砖引玉. 对此佛具 (talk) 02:36, 7 August 2024 (UTC)
- 伪静态设置
- $wgScriptPath = ""; // 确保为空,如果你的MediaWiki安装在服务器的根目录
- $wgArticlePath = "/w/$1"; // 短 URL 设置,确保与服务器配置匹配
- $wgUsePathInfo = true; // 使用路径信息
- $wgScriptExtension = ".php"; // PHP 文件扩展名
- $wgLoadScript = "{$wgScriptPath}/load.php"; 对此佛具 (talk) 02:37, 7 August 2024 (UTC)
- 启用 URL 重写
- RewriteEngine On
- 排除静态资源和脚本文件不进行重写
- RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|less)$ [NC]
- RewriteCond %{REQUEST_URI} !^/load.php [NC]
- RewriteCond %{REQUEST_URI} !^/api.php [NC]
- 将 /wiki/ 目录下的请求映射到 /index.php?title=...
- RewriteRule ^wiki/(.*)$ /index.php?title=$1 [L,QSA]
- 将其他请求重定向到 /index.php
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ /index.php [L,QSA] 对此佛具 (talk) 02:38, 7 August 2024 (UTC)
- 启用 URL 重写
- <Directory /www/wwwroot/base/w>
- Options +FollowSymLinks
- AllowOverride All
- Require all granted
- </Directory> 对此佛具 (talk) 02:38, 7 August 2024 (UTC)