无法获取的mediawiki的.htaccess短网址工作: [英] Unable to get Mediawiki .htaccess Short URL to work:

查看:325
本文介绍了无法获取的mediawiki的.htaccess短网址工作:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了这样的链接到MediaWiki:

I have mediawiki set up like this:

mysite.com/w/

我想添加的短网址的方法喜欢这里的手册中建议:

I am trying to add the Short URL method like it suggested in the manual here:

https://www.mediawiki.org/wiki/Manual:Short_URL/Apache

我用redwerks工具生成的.htaccess重写规则:

I used the redwerks tool to generate the .htaccess rewriting rules:

http://shorturls.redwerks.org/

虽然我在VPS以root权限,我发现改变了Apache的配置和Nginx的配置过于复杂,这样在我的头上。所以我决定去与htaccess的方法,我不可能让它完全工作。这就是我说的.htaccess文件中的根路径:

Although I am on VPS with root access, I find changing the Apache config and Nginx config to be too complicated and way over my head. So I decided to go with the htaccess method and I couldnt get it to work completely. This is what I added the .htaccess file in the root path:

RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/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=$1&width=$2 [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=$1&width=$2&archived=1 [L,QSA,B]

和我说这些的的LocalSettings.php

And I Added these to the LocalSettings.php

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads  = true;

以上后,重定向类作品。意思是,如果我去mysite.com/w/index.php/Page_Title,它重定向到mysite.com/wiki/Page_Title。但接下来的does not工作:

After the above, the redirection sort of works. Meaning, if I go to mysite.com/w/index.php/Page_Title, it redirects to mysite.com/wiki/Page_Title. But the following doesnt work:

1)当我输入mysite.com/wiki,它不找到该网页并且不自动转到主页像以前那样做时,我输入mysite.com/w/。所以,我需要添加一个单独的重写规则呢?

1) When I type in mysite.com/wiki, it doesnt find the page and doesnt automatically goes to Main Page like it used to do when I typed mysite.com/w/. So do I need to add a separate Rewrite rule for this?

2)我也收到找不到一个页面,它创建一个新的文章页面时,URL看起来像:mysite.com/wiki/index.php。在这种情况下,它试图建立引导我主页的一个的index.php文章。

2) I am also receiving a page not found and its creating a new article page when the url looks like: mysite.com/wiki/index.php. In this case, it is trying to create a index.php article instead of directing me to Main Page.

3)即使上面的规则是,当我到不是主文章页面的其他页面,如编辑网页或查看历史记录,等等。它仍然显示的网址为mysite.com/w/index ?.PHP标题= XYZ和放大器;行动=编辑。为什么犯规将其转换所有URL以维基?

3) Even when the above rule is on, when I got to pages other than the main article page, such as edit a page or view history, etc.. it still shows the url as mysite.com/w/index.php?title=XYZ&action=edit. Why doesnt it convert all urls to wiki?

4)如果网址有?标题添加到它,它不重定向到维基。例如,当前页mysite.com/w/index.php?title=Main页,不成为mysite.com/wiki/Main_Page

4) If a url has a ?title added to it, it doesnt get redirected to wiki. For example, this page mysite.com/w/index.php?title=Main Page, does not become mysite.com/wiki/Main_Page

看到上面后,现在我想,如果它能够更好地拥有我的wiki安装mysite.com/wiki/~~V文件夹而不是'W'文件夹。逸岸,这是我怎么过它第一次,但后来改变了它,当我试图实现短网址的方法,因为兆瓦手册建议反对。所以,我需要就如何解决这方面的一些指导,请...

After seeing the above, now I am thinking if its better to have my wiki installation to mysite.com/wiki/ folder instead of 'w' folder. Infact thats how I had it first but later changed it when I trying to implement the Short URL method since the MW Manual suggests against it. So I need some guidance on how to resolve this please...

这些都只是一些我到目前为止发现的问题。所以基本上重写规则犯规完全重写的所有页面。它只有从URL中移除的index.php /和改变W至维基重写主文章页面的URL。但其他URL类型仍然是相同的,并没有被改写。当我检查MediaWiki的网站上,所有的网址编辑页面,等等,即使被改写为/维基/没有的index.php。我怎样才能得到同样的结果?

These are just some of the issues I've noticed so far. So basically rewrite rule doesnt completely rewrite all the pages. It only rewriting the main article page url by removing the index.php/ from the url and changing w to wiki. But other urls types are still the same and are not rewritten. When I checked the mediawiki website, all of their urls are rewritten to /wiki/ without the index.php even when editing page, etc.. How can I get the same results?

推荐答案

好了以后再寻找在网上,这是我发现了什么。

Okay after further searching on the net, this is what I found.

即使上面的规则是,当我到比其他网页   主要文章页面,如编辑网页或查看历史记录,等等。它仍然   显示网址mysite.com/w/index.php?title=XYZ&action=edit。为什么   犯规将其转换所有URL以维基?

Even when the above rule is on, when I got to pages other than the main article page, such as edit a page or view history, etc.. it still shows the url as mysite.com/w/index.php?title=XYZ&action=edit. Why doesnt it convert all urls to wiki?

这是怎么它应该工作。因此,这意味着主网页,命名空间页面和专页都会有这样的短网址,而其他页面一样编辑页面,历史记录等。仍将显示瓦特/ index.php文件/......

This is how its supposed to work. So this means the Main pages, Namespace pages and Special Pages will have this short url while the other pages like edit page, history, etc.. will still show w/index.php/......

如果一个url有?标题添加到它,它不重定向到维基。   例如,此页面mysite.com/w/index.php?title=Main页,不   不能成为mysite.com/wiki/Main_Page

If a url has a ?title added to it, it doesnt get redirected to wiki. For example, this page mysite.com/w/index.php?title=Main Page, does not become mysite.com/wiki/Main_Page

这只是重写文章的网址,我不应该包括哪些内容?1标题= $或类似的东西在改写。包括一个查询将导致建在处理被重写MediaWiki的和将上创建维基错误由于这样的事实,Apache的查询重写被打破。这里的目标是别名路径的index.php,然后让链接到MediaWiki本身采取的解析和路由URL的护理的基础上,在LocalSettings.php中配置。

It only rewrites the article urls and I should never include ?title=$1 or something like it in the rewrite. Including a query will cause MediaWiki's built in handling to be overridden and will create bugs on your wiki due to the fact that Apache's query rewrites are broken. The goal here is to alias paths to /index.php and then let MediaWiki itself take care of parsing and routing the url, based on the configuration in LocalSettings.php.

因此​​,基本上重写规则犯规完全重写的所有页面。它   只有通过删除的index.php重写主文章页面的URL /   从URL和改变瓦到维基。但其他URL类型仍   相同的,并且不重写。

So basically rewrite rule doesnt completely rewrite all the pages. It only rewriting the main article page url by removing the index.php/ from the url and changing w to wiki. But other urls types are still the same and are not rewritten.

我后来发现,这就是它是如何工作的。

I later found out that thats how it is supposed to work.

我还没有找到一个答案为1和2。我想我需要添加一个单独的重定向规则的。我曾问一个单独的问题找到了htaccess的重写规则:<一href="http://stackoverflow.com/questions/18843356/how-to-redirect-mediawiki-short-url-with-no-title-to-main-page">How重定向的mediawiki短网址,没有标题为主页?

I am yet to find an answer for 1 and 2. I think I need to add a separate redirect rule for that. I have asked a separate question to find the htaccess rewrite rule for that: How to redirect Mediawiki Short URL with no title to Main Page?

一旦我有了答案那些我会更新这个话题。

I will update this topic once I have the answer for those..

更新:

有关NO:1,我只需要到其他重写规则之前,需要将重写规则顶端,之后它的工作。更多信息:<一href="http://stackoverflow.com/questions/18843356/how-to-redirect-mediawiki-short-url-with-no-title-to-main-page/18882999#18882999">How重定向的mediawiki短网址,没有标题为主页?

For no: 1, I just need to move the rewrite rule to the top before other rewrite rules and it worked after that. More info: How to redirect Mediawiki Short URL with no title to Main Page?

有关无:2:维基/ index.php文件将不被重定向到维基/ Main_Page,因为它会看的index.php作为一个新的文章。它只会重定向W / index.php来/维基/ Main_Page

For no: 2: wiki/index.php will not be redirected to wiki/Main_Page since it will look at index.php as a new article. It will only redirect w/index.php to /wiki/Main_Page

这篇关于无法获取的mediawiki的.htaccess短网址工作:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆