Make a second url link to the same directory as a

2019-08-17 18:38发布

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

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.

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.

1条回答
爷的心禁止访问
2楼-- · 2019-08-17 19:13

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

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).

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();

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!

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!

查看更多
登录 后发表回答