Difference between revisions of "MediaWiki/archive/customizing/URLs"
(→Using mod_rewrite: settings for subfolder wiki) |
|||
Line 10: | Line 10: | ||
This is probably documented elsewhere, but this is what actually worked on a shared server without root access or a shell. | This is probably documented elsewhere, but this is what actually worked on a shared server without root access or a shell. | ||
− | + | ||
First, the .htaccess file needs to include: | First, the .htaccess file needs to include: | ||
Line 24: | Line 24: | ||
Second, modify LocalSettings.php: | Second, modify LocalSettings.php: | ||
− | :$wgArticlePath | + | :$wgScriptPath = ''; |
+ | :wgArticlePath = $wgScriptPath.'/$1'; | ||
+ | |||
+ | This assumes MediaWiki is installed in the root of the www pages, e.g. <nowiki>http://yourdomain.com/Main_Page</nowiki> is the wiki's main page; if you have it in a subfolder, e.g. <nowiki>http://yourdomain.com/wiki/Main_Page</nowiki>, then: | ||
+ | |||
+ | :$wgScriptPath = '/wiki'; | ||
Then do ?action=purge on any page to test it. Internal links on existing pages will convert to the new URLs any time they are saved or purged. | Then do ?action=purge on any page to test it. Internal links on existing pages will convert to the new URLs any time they are saved or purged. | ||
− | The above seems to work for everything (including editing) without breaking old-style URLs | + | The above seems to work for everything (including editing) without breaking old-style URLs. |
This method is also documented here, with some minor changes: http://wiki.welldesignedurls.org/Clean_Urls_for_MediaWiki | This method is also documented here, with some minor changes: http://wiki.welldesignedurls.org/Clean_Urls_for_MediaWiki | ||
Line 35: | Line 40: | ||
* proper handling of page named [[.htaccess]] (click on that for a demonstration of the problem) | * proper handling of page named [[.htaccess]] (click on that for a demonstration of the problem) | ||
* ability to have the wiki installed in a subdirectory while still making it appear to be in the domain's root folder | * ability to have the wiki installed in a subdirectory while still making it appear to be in the domain's root folder | ||
+ | |||
==Comments== | ==Comments== | ||
Please feel free to post comments here or on the Talk page if you try any of these procedures. | Please feel free to post comments here or on the Talk page if you try any of these procedures. |
Revision as of 16:04, 2 December 2007
nocaaccae
computing: software: web: MediaWiki: customization: shortening MediaWiki URLs
Overview
The most reliable method seems to be the mod_rewrite, which requires access to either httpd.conf or requires particular handling options for .htaccess to be switched on (fortunately, they usually seem to be). Failing that, another method is:
Some additional methods are documented here.
Using mod_rewrite
This is probably documented elsewhere, but this is what actually worked on a shared server without root access or a shell.
First, the .htaccess file needs to include:
|
Second, modify LocalSettings.php:
- $wgScriptPath = ;
- wgArticlePath = $wgScriptPath.'/$1';
This assumes MediaWiki is installed in the root of the www pages, e.g. http://yourdomain.com/Main_Page is the wiki's main page; if you have it in a subfolder, e.g. http://yourdomain.com/wiki/Main_Page, then:
- $wgScriptPath = '/wiki';
Then do ?action=purge on any page to test it. Internal links on existing pages will convert to the new URLs any time they are saved or purged.
The above seems to work for everything (including editing) without breaking old-style URLs.
This method is also documented here, with some minor changes: http://wiki.welldesignedurls.org/Clean_Urls_for_MediaWiki
Wish list:
- proper handling of page named .htaccess (click on that for a demonstration of the problem)
- ability to have the wiki installed in a subdirectory while still making it appear to be in the domain's root folder
Comments
Please feel free to post comments here or on the Talk page if you try any of these procedures.
6/23/2007: I used your .htaccess and then set $wgArticlePath = "$wgScriptPath/$1";. This way the forwarding works regardless of what directory the wiki is located in. In my case it was /wiki. --Jordan Mendler (jmendlerspam@spamuclaspam.spamedu)