在不将内容复制到第二个目录的情况下,使第二个URL链接到与其他URL相同的目录吗? [英] Make a second url link to the same directory as a different url, without copying the content to a second directory?

查看:103
本文介绍了在不将内容复制到第二个目录的情况下,使第二个URL链接到与其他URL相同的目录吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 w目录中有文件,并且我希望可以从其他目录访问这些相同的文件。

I have files in a directory, "w", and I want to have those same files accessible from a different directory.

我在 w目录中安装了MediaWiki,并创建了一个简短的URL以链接到 Wiki URL。我的文件位于 w目录中,但可以从 http://example.com/wiki。我想要第二个Wiki,其网址格式完全为 http://example.com/second-wiki

I have a MediaWiki installation in the directory 'w', creating a short url to link to the url 'wiki'. I have the files in the 'w' directory but it can be accessed from http://example.com/wiki. I want to have a second wiki entirely with the url format of http://example.com/second-wiki.

由于MediaWiki使用的是数据库中文件的内容,因此代码实际上并不需要更改,即使LocalSettings.php也是如此。我通过使用带有输入信息(例如要使用的url)的数据库表来建立数据库系统,修改MediaWiki系统并在单个数据库中创建多wiki支持。或者甚至使用相同的文件,并将localsettings.php文件添加到目录 w2,但使用原始目录 w中的其他所有文件。这可能吗?最好使用.htaccess或其他易于编辑的方式。我不希望对php配置进行任何更改。

Since MediaWiki uses the content of files from a database the code never actually needs to change, even the LocalSettings.php. I set up a database system, modified the MediaWiki system, and created multi wiki support in a single database, by using a database table with input information such as the url to use. Or even use the same files and add a localsettings.php file to a directory 'w2' but use everything else from the original directory, 'w'. Is this possible? Preferably using .htaccess, or some other equally easy to edit. I don't want any changes to php configuration though.

推荐答案

我相信这可能会有所帮助……-这是用PHP完成的简单重定向,因此很容易以后编辑等等。

I believe this may help...... - it is a simple redirect done in PHP so it is easy to edit later, etc.

我将处理一个事实,即您有一个 http://example.com/wiki ,而您想通过 http://example.com/second-wiki (其中将执行魔术操作以实际打开另一个URL)。

I'll work with the fact you have a 'w' directory accessed by http://example.com/wiki and you want to access that through http://example.com/second-wiki (where 'magic' will be done to actually open the other URL).

'w2'文件夹,创建一个具有以下内容的index.php文件:

In the 'w2' folder, make an index.php file with the following contents:

<?php
header("Location: ../w"); 
// NOTE: you may need to make that w/index.php or other pointer
exit();

现在,只要您访问 http://example.com/second-wiki ,您实际上会看到 http://example.com/wiki

Now, any time you access http://example.com/second-wiki, you will actually see http://example.com/wiki

如果需要,以后可以轻松更改!

Simple and easy to change later if you need to!

从问题中不确定这是否是解决方案(它适合主题和某些问题文本,尽管问题文本确实跳跃了一下……)-如果不是,请将问题改写成更清楚的说明(在一个地方,您说代码实际上并不需要更改,甚至LocalSettings.php –然后在另一个地方,您谈论需要单独的设置.. )-但是,如果您正在寻找使多个URL指向同一文件夹的最简单(IMHO)方法,那么这就是要走的路-纯PHP且以后易于修改!

Not sure from the question that this is the solution (it fits the topic and some of the question text, though the question text does 'jump around' a bit...) - if it isn't, please rephrase the question to be more clear on just what you are looking for (in one place you say "the code never actually needs to change, even the LocalSettings.php" - then in another you talk about needing separate settings.....) - however, if you are looking for the 'simplest' (IMHO) way to make multiple URLs point to the same folder, this is the way to go - pure PHP and easy to mod later!

这篇关于在不将内容复制到第二个目录的情况下,使第二个URL链接到与其他URL相同的目录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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