MediaWiki Apache2 RewriteEngine 不工作

MediaWiki Apache2 RewriteEngine 不工作

我正在工作手册:短网址/Apache 指南在运行 Apache2 的 Debian 服务器上设置具有缩短的 URL 的 wiki。

我希望目录 /var/www/currienet/w/ 可以在 currienet/wiki/ (本地网络地址)上访问

我在 httpd.conf 文件中有以下内容:

<VirtualHost *:80>
      ServerName http://currienet
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /var/www/currienet/root/
      <Directory /var/www/currienet/root>
        Allow from all
      </Directory>


        <Directory /var/www/currienet/w/>

        </Directory>

      # Alias /wiki '/var/www/currienet/w'
      LogLevel debug

      # Enable the rewrite engine
      RewriteEngine On

      # Short url for wiki pages
      RewriteRule ^/?wiki(/.*)?$ /var/www/currienet/w/index.php [L]
</VirtualHost>

并在 LocalSettings.php 中进行以下设置

$wgScriptPath       = "/w";
$wgArticlePath = "/wiki/$1";

当我尝试访问 currienet/wiki 时,我看到了主页,但是没有任何图像、样式表等加载,并且在 Apache 错误日志中看到以下内容(出于安全考虑,IP 已被阻止):

[Tue Oct ***.***.***.*** 2012] [notice] Apache/2.2.22 (Debian) Phusion_Passenger/3.0.17 PHP/5.4.4-2 configured -- resuming normal operations
[Tue Oct ***.***.***.*** 2012] [error] [client ***.***.***.***] File does not exist: /var/www/currienet/root/w, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [debug] mod_deflate.c(615): [client ***.***.***.***] Zlib: Compressed 283 to 216 : URL /w/load.php, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [error] [client ***.***.***.***] File does not exist: /var/www/currienet/root/w, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [debug] mod_deflate.c(615): [client ***.***.***.***] Zlib: Compressed 283 to 216 : URL /w/load.php, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [error] [client ***.***.***.***] File does not exist: /var/www/currienet/root/w, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [debug] mod_deflate.c(615): [client ***.***.***.***] Zlib: Compressed 283 to 216 : URL /w/load.php, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [error] [client ***.***.***.***] File does not exist: /var/www/currienet/root/w, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [debug] mod_deflate.c(615): [client ***.***.***.***] Zlib: Compressed 324 to 248 : URL /w/skins/common/images/poweredby_mediawiki_88x31.png, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [debug] mod_deflate.c(615): [client ***.***.***.***] Zlib: Compressed 0 to 2 : URL /wiki/images/swan.png, referer: http://currienet/wiki/Main_Page
[Tue Oct ***.***.***.*** 2012] [debug] mod_deflate.c(615): [client ***.***.***.***] Zlib: Compressed 11292 to 3748 : URL /wiki/Images/swan.png, referer: http://currienet/wiki/Main_Page

other_vhosts_access.log 中的内容如下:

currienet:***.***.***.***.96 - - [02/Oct/2***.***.***.*** +0800] "GET /wiki/Main_Page HTTP/1.1" 304 276 "http://currienet/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
currienet:***.***.***.***.96 - - [02/Oct/2***.***.***.*** +0800] "GET /w/load.php?debug=false&lang=en-gb&modules=mediawiki.legacy.commonPrint%2Cshared%7Cskins.vector&only=styles&skin=vector&* HTTP/1.1" 404 497 "http://currienet/wiki/Main_Page" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
currienet:***.***.***.***.96 - - [02/Oct/2***.***.***.*** +0800] "GET /w/load.php?debug=false&lang=en-gb&modules=startup&only=scripts&skin=vector&* HTTP/1.1" 404 498 "http://currienet/wiki/Main_Page" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
currienet:***.***.***.***.96 - - [02/Oct/2***.***.***.*** +0800] "GET /w/load.php?debug=false&lang=en-gb&modules=skins.vector&only=scripts&skin=vector&* HTTP/1.1" 404 498 "http://currienet/wiki/Main_Page" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
currienet:***.***.***.***.96 - - [02/Oct/2***.***.***.*** +0800] "GET /w/skins/common/images/poweredby_mediawiki_88x31.png HTTP/1.1" 404 530 "http://currienet/wiki/Main_Page" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
currienet:***.***.***.***.96 - - [02/Oct/2***.***.***.*** +0800] "GET /wiki/images/swan.png HTTP/1.1" 301 539 "http://currienet/wiki/Main_Page" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
currienet:***.***.***.***.96 - - [02/Oct/2***.***.***.*** +0800] "GET /wiki/Images/swan.png HTTP/1.1" 404 4209 "http://currienet/wiki/Main_Page" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
currienet:80 ::1 - - [02/Oct/2***.***.***.*** +0800] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Debian) (internal dummy connection)"
currienet:80 ::1 - - [02/Oct/2***.***.***.*** +0800] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Debian) (internal dummy connection)"

答案1

您的 Apache 配置有一些错误。

ServerName http://currienet

这应该是不带 http:// 的网站域名

ServerName currienet.blah.com

该目录块应明确说明其选项和访问权限。

<Directory /var/www/currienet/w/>
Order Allow,Deny
Allow from all
</Directory>

您已注释掉所需的一行:

# Alias /wiki '/var/www/currienet/w'

此外,您应该在 wiki 上有一个以 / 结尾的别名行。

Alias /wiki/ '/var/www/currienet/w/'

现在,重写。重写规则用于将一个 URL 映射到另一个 URL,而不是将 URL 映射到目录。

  # Short url for wiki pages
  RewriteRule ^/?wiki(/.*)?$ /var/www/currienet/w/index.php [L]

这不会按照您的预期执行(它将尝试提供http://YOURSITE/var/www/currienet/w/index.php可能不存在的页面)。如果您已将 Alias 指令放置到位并已正确设置该目录的目录选项,则您不需要任何重写规则。

相关内容