PDA

View Full Version : MediaWiki: Short URLs possible?


paradox
10-22-2006, 05:53 PM
Hi,

In addition to my previous question (refreshLinks), I was wondering if short URLs are possible here? I've tried to implement them as per http://www.mediawiki.org/wiki/Manual:Short_url and http://meta.wikimedia.org/wiki/Using_a_very_short_URL but to no avail. Any suggestions?

Thanks.

Bill
10-27-2006, 04:46 AM
Hello,

If you want to use the short URLs, I advise you to proceed as shown in the example below:

For example, install the wiki in /main, and have the following set in LocalSettings.php:

$wgArticlePath = "/wiki/$1";

Then, add the following in the main .htaccess file

RewriteEngine on
RewriteRule ^wiki/(.*)$ /main/index.php?title=$1 [L,QSA]

Please try that and make sure you have no other .htaccess files in the directory above the wiki one.

trailville
11-19-2006, 08:33 PM
I've tried this along with numerous variations I've fount on other websites and am unable to get it to work.

The .htaccess stuff seems to work because it will allow accessing the site with a short URL (before changing LocalSettings.php).

However, once I change the $wgArticlePath variable to point to the clean format, I receive errors which seem to relate to problems with the $wgScriptPath variable which I did not change (it still points to the original physical directory). Basically I get a php error that points to a line in the code in LocalSettings.php with is the first instance where the variable $wgScriptPath is used.

trailville
11-20-2006, 06:43 PM
I got mine working thanks to posts on the mediawiki user forum at
http://www.mwusers.com/forums/showthread.php?t=950

I thought I would include the changes here in case anyone else wants to do the same thing.

My wiki is installed in /public_html/wiki and the clean url for my main page now comes up as http://www.trailville.com/wiki/Main_Page

added the following to .htaccess file located in /public_html
__________________________________________________ _
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.+)$ /wiki/index.php?title=$1 [L,QSA]
__________________________________________________ ____


changed the following in LocalSettings.php located in /public_html/wiki
__________________________________________________ _________
$wgScriptPath = "/wiki";
$wgScript = "$wgScriptPath/index.php";
$wgRedirectScript = "$wgScriptPath/redirect.php";

## For more information on customizing the URLs please see:
## http://meta.wikimedia.org/wiki/Eliminating_index.php_from_the_url
## If using PHP as a CGI module, the ?title= style usually must be used.
## $wgArticlePath = "$wgScript?title=$1";
$wgArticlePath = "$wgScriptPath/$1";
__________________________________________________ ___________

Shadow_Guyver
10-05-2007, 01:25 AM
I've recently been attempting to have the Short URLs available for my wiki, but I've tried installing all the codes mentioned in this particular thread and the help info from the mediawiki.org tutorial and I still get that 404 error. The site I'm working on is eWikiMall.com and it's been REALLY frustrating. I have tried inputting the following code:

added the following to .htaccess file located in /public_html
__________________________________________________ _
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.+)$ /wiki/index.php?title=$1 [L,QSA]
__________________________________________________ ____


changed the following in LocalSettings.php located in /public_html/wiki
__________________________________________________ _________
$wgScriptPath = "/wiki";
$wgScript = "$wgScriptPath/index.php";
$wgRedirectScript = "$wgScriptPath/redirect.php";

## For more information on customizing the URLs please see:
## http://meta.wikimedia.org/wiki/Elimi...p_from_the_url
## If using PHP as a CGI module, the ?title= style usually must be used.
## $wgArticlePath = "$wgScript?title=$1";
$wgArticlePath = "$wgScriptPath/$1";
__________________________________________________ ___________

my wiki files are stored in the public_html/wiki directory. do I need to replace the above script in the LocalSettings.php or merely add it? The problem is that I don't see the inclusion of this line ($wgScriptExtension = ".php"; ) in the above script. The only place I can see to replace it is here:
__________________________________________________ ____________
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
$wgScriptPath = "/Wiki"; <=Right Here?????
$wgScriptExtension = ".php"; <=Right Here?????

## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL

$wgEnableEmail = true;
$wgEnableUserEmail = true;
__________________________________________________ _____________

If someone could help me, It would be greatly appreciated

Dan
10-05-2007, 07:37 AM
It will be easier to set the ShortURLs if create a subdomain wiki.your_domain.com.

If you have your application set on subdomain you may check the following URL for more infomration how to set it with ShortURL:

http://www.mediawiki.org/wiki/Manual:Short_URL

I have checked the method and it is working fine.

Note that you should also contact your web hosting (http://www.siteground.com) as it seems that the domain eWikiMall.com is not hosted with SiteGound and ask them if the mod_rewrite engine is enabled.

Shadow_Guyver
10-05-2007, 11:02 AM
So there is no other way around this but to create a subdomain? I didn't even want to show the /wiki folder let alone create another subdomain. If I transfer over my domain hosting from my original hosting company, would that make a difference?

trailville
10-05-2007, 06:27 PM
The specific code required to get this to work tends to vary somewhat depending on how your host has their servers set up. I was equally aggravated when I was trying to get mine to work since code listed on some sites as working would not work with mine. The solution I provided above is working on my Siteground hosted site with the wiki located in /public_html/wiki , but may very well not work if you are not hosted with Siteground. In fact, it may not even work with another siteground site if siteground doesn't have all their servers set up the same.
I don't know where your site is hosted, but it can be much less aggravating if you host with a host that has a focus on mediawiki (or at least a lot of customers that use mediawiki).

As to your question about adding or replacing the script in your localsettings.php file, you should always search the file for each variable and change it if it already exists. If it doesn't exist, you can add it. The individual variables you need to change (each line in the script) may not necessarily be grouped together in the file, so search for them individually.

Shadow_Guyver
10-06-2007, 01:55 PM
Well, My site is hosted with SiteGround, however, my domain is registered with a different company (1and1.com). This is pretty frustrating because I really do want to clean up the URL. I was wondering if it was possible for me to request help from the Siteground admin to actually fix this problem. If it is a matter of cost, I would pay to remedy the situation.

George Y.
10-08-2007, 07:37 AM
Hi,

Please note that there is no difference which is your registrar -- as long as your domain name is pointed to our server and your account is properly accessible via your domain there is not problem to set the wiki short URLs.

You can post a ticket under script installation category and our support team will be glad to set it for you.

Shadow_Guyver
10-10-2007, 01:10 AM
It looks like finally it's working for my site. My friend was able to help me with editing the file. Apparently, he mentioned that the page directories (like "/wiki") are case sensitive? I guess I had the directory labelled "/Wiki" but I kept typing in all in lower case. Thanks everyone for your help!

Collin1000
10-10-2007, 08:14 PM
The Apache webserver is case sensitieve, indeed. This is a common mistake and I myself forgot it last night when coding a mod for IPB. Oopsie! :P

BradLee
04-22-2009, 05:05 PM
I have tried doing this with my website for 3 days now, tried every combination/variation of code posted, and I am still having no luck.

Can someone PLEASE help me out with this?

Firstly I am trying to do this on a subdomain of my website.
The address is http://private.smileypedia.org
The folder that this corresponds with is /public_html/private/
So there is no "wiki' or "w" folder involved.

There are two .htaccess files available, and I have tried posting the rewrite conditions into both.

The first is located in /public_html/ which I am assuming is NOT the one I want correct?
The second is located in /public_html/private/ which I assuming is the CORRECT one? (and is the directory where my wiki is installed)

Next:
I have modified the LocalSettings.php file located in /public_html/private/ (which is the same directory where the .htaccess file is stored).

I am pretty sure that this is the right LocalSettings.php file, because this is where I have also made some other changes that have successfully affected my wiki.

So:
The pages seem to be redirected successfully, as hovering over the links shows the short URLs, but whenever I click on one of them I get a 404 error.

BradLee
04-22-2009, 05:15 PM
No way, I got it working...

The problem was in the RewriteRule ^wiki/(.*)$ /index.php?title=$1 [L,QSA] line.

Of course there is no wiki directory in my case, so it needed to be rewritten as:
RewriteRule ^(.*)$ /index.php?title=$1 [L,QSA]

DOH.