Make a second url link to the same directory as a different url, without copying the content to a second directory?

浪子不回头ぞ 提交于 2019-12-13 03:10:28

问题


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:


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!



来源:https://stackoverflow.com/questions/55385069/make-a-second-url-link-to-the-same-directory-as-a-different-url-without-copying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!