this is clunky as hell. is short URLs by default on the roadmap?
Manual talk:Short URL
URLs on my wiki looked like this immediately after install:
[myserver]/index.php?title=Main_Page
After configuring short URLs per this article, the above URL still "works" without CSS, but all links point to URLs like this:
[myserver]/wiki/Main_Page
These are the correct URLs, but they 404. Worse still, reverting the changes to /etc/httpd/conf/httpd.conf and /var/www/mediawiki/LocalSettings.conf does not revert to the default behavior even after reloading or restarting the service or restarting the server.
How do I fix this?
I figured it out. When using the default httpd config for RHEL, the following changes need to be made:
- The only change to
/etc/httpd/conf/httpd.conf
should be to setAllowOverride All
under<Directory "/var/www/mediawiki">
. - Set the following in
/var/www/mediawiki/.htaccess
:
RewriteEngine On RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L] RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]
- Note that the
/w
was removed from the last two lines. - Set the following in
/var/www/mediawiki/LocalSettings.php
:
$wgScriptPath = ""; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
- Note that
$wgScriptPath
has been set to blank.
I hope anyone can help me. I have a hosted webspace and I have installed MediaWiki without any extensions in https://abcd.com/wiki
when go on the set I will be redirected to https://abcd.com/wiki/index.php/Hauptseite (it is a german wiki). But I want the short url https://abcd.com/wiki/Hauptseite
I have made a .htaccess File in the https://abcd.com/wiki/ folder with this:
RewriteEngine On
RewriteRule ^wiki/(.*)$ wiki/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ wiki/index.php [L,QSA]
RewriteRule ^wiki$ wiki/index.php [L,QSA]
And in the LocalSettings.php I set:
$wgScriptPath = "/wiki";
$wgArticlePath = "$wgScriptPath/$1";
When I now go the wiki I get the error I will redirected to https://abcd.com/wiki/Hauptseite
and get this error:
Not Found
The requested URL /wiki/Hauptseite was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I have no more ideas... Thank you for help a frustrated man ;)
did you able to solve that? I have the same problem either
https://shorturls.redwerks.org/ this worked for me :)
In the OP's post he says he is using a hosted webspace, therefore the https://shorturls.redwerks.org/ link you provided wont half, as this required root access to modify the server. I am in the same boat, btw, and cannot get this working on a shared hosting.
I'm not sure if this is the correct location for the question, but I'll ask anyway.
I'm trying to change my URL from http://127.0.0.1/www/maikalpedia.com/index.php/Main_Page to just http://maikalpedia.com/wiki/Main_Page, but not matter what I do, I just can't change it. Here are the LocalSettings.php:
$wgScriptPath = "/www/maikalpedia.com";
$wgScriptExtension = ".php";
$wgArticlePath = "$wgScriptPath/index.php/$1";
$wgServer = "http://127.0.0.1";
I'm stumped, and I should note that this is the first time I've created a MediaWiki of my own. Any help would be great. Thanks.
$wgArticlePath = "/wiki/$1";
Okay, I changed $wgArticlePath to "/wiki/$1", but URL remains http://127.0.0.1/www/maikalpedia.com/index.php/Main_Page. Was that all I was suppose change?
Excellent it worked. Now the only issue is that the link says "This webpage is not available". Is there anything I need to do to fix that, or is it just the $wgScriptPath?
I used this guide to setup nice short URLs setup for my wiki like /w/Main_Page
and /w/Main_Page/edit
, but VisualEditor seems to force URLs like index.php?title=Main_Page&veaction=edit
, which when clicked on does a redirect to /w/Main_Page?veaction=edit
which is still fairly ugly. Is there any way to work around this? I can find zero mentions of this behavior anywhere across MediaWiki or in any other documentation.
I reported a similar issue as task T270376 I am pretty sure that you are currently out of luck.
Greetings.
My wiki is located at site.com/wiki.
for years I used the short url site.com/a/
recently I changed the short url to site.com/w/
I just realized that all the links that used /a/ no longer work (duh) is there a way that I can tell apache to continue to direct those old links to the new address?
Hello. My private test wiki is located on Apache server at https://wiki.rehman.website/w/index.php (/home/var/wiki.rehman.website/w/)
I have added .htaccess in /home/var/wiki.rehman.website/.htaccess with the following (as per Manual:Short URL/Apache):
RewriteEngine On # main rewrite rule RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L] # Redirect / to Main Page RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
With these settings in LocalSettings.php:
$wgScriptPath = "/w"; $wgArticlePath = "/wiki/$1";
But when browsing to https://wiki.rehman.website/ the page loads in a bad formatting (as if something is broken). And clicking on any of the links on this page generates this error:
Not Found The requested URL was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
What am I doing wrong? Any help is appreciated. Many thanks!
You have your script directory as your DOCUMENT_ROOT, while the documentation assumes you have your MediaWiki directory in a subdirectory named /w
. You should be able to fix this by changing "/w/index.php" to "/index.php" in your .htaccess and then set $wgScriptPath = "/";
Thanks @Þjarkur. I've updated .htaccess
per above, but unfortunately the output is still the same, strangely.
For the sake of trying, I've run shorturls.redwerks.org as mentioned at Manual:Short URL/Apache#Setup. Oddly though, the settings mentioned there are different from the official Short URL guidelines.
The redwerks links suggested that I add the below code to .htaccess:
RewriteEngine On RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
And the below code/amendments to LocalSettings.php:
$wgScriptPath = ""; $wgScriptExtension = ".php"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true; $wgEnableUploads = true; $wgGenerateThumbnailOnParse = false;
And to increase my frustration, that too, did not work. The landing page worked, but I cannot go beyond the login link (ends in the same error above). It seems like something has changed since the Short URL was documented, or this doesn't work with private wikis, or some other compatibility issue...
The above https://shorturls.redwerks.org/ code was with the Include 404 thumbnail handler config
ticked. Without the option, it suggested adding the below code to .htaccess:
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]
And the below code/amendments to LocalSettings.php:
$wgScriptPath = ""; $wgScriptExtension = ".php"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
This too, did not work, even with public read access enabled.
Could this issue persist because I have the word "wiki" as part of the URL (i.e. "wiki.rehman.website/etc")?
i'm a little confused by your description. To clarify: Which directory is the .htaccess file in? Is your last comment the current value of the .htaccess? Which directory is your web root directory?
> Could this issue persist because I have the word "wiki" as part of the URL (i.e. "wiki.rehman.website/etc")?
No, that should not matter
Hi @Bawolff. As of my last comment, I had undid those changes. For the sake of troubleshooting, I have now restored the below settings (and made the test wiki publicly readable):
htaccess:
RewriteEngine On # main rewrite rule RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L] # Redirect / to Main Page RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
I had also tried removing /w
.
LocalSettings.php:
$wgScriptPath = "/w"; $wgArticlePath = "/wiki/$1";
And these are the directories:
- MediaWiki is located at:
/home/<user>/wiki.rehman.website/w/index.php
- .htaccess is located at:
/home/<user>/wiki.rehman.website/.htaccess
- Root directory is set as
wiki.rehman.website/w/
I have also tried moving the htaccess to /home/<user>/wiki.rehman.website/w/.htaccess
, but nothing works. Thank you.
i think he confusion comes because the instructions you are following are for if your web root diectory is /home/<user>/wiki.rehman.website/ and mediawiki is installed in a subdirectory named w. If your web root is /home/<user>/wiki.rehman.website/w/ then these instructions expect mediawiki to be installed in /home/<user>/wiki.rehman.website/w/w/
I eventually realised the same too, and hence I did also try other options (as mentioned in previous posts). They all didn't work. If you don't mind, could you help in writing the correct htaccess and LocalSettings codes for my setup please?
Looking at your configuration
Your Script path is /w, but it should be /
Everything else seems correct
Thanks for the reply @Ciencia Al Poder. Unfortunately, that too did not work. I'm going to delete the whole wiki and retry. I think there is a bug somewhere. Will update here again. Cheers.
In your previous comment you had:
.htaccess in /home/<user>/wiki.rehman.website/.htaccess
if your web root is /home/<user>/wiki.rehman.website/w then placing your your htaccess in /home/<user>/wiki.rehman.website/.htaccess will mean it is totally ignored. The correct place would be /home/<user>/wiki.rehman.website/w/.htaccess
Additionally, I think the rewrite rules were wrong because they had an extra /w/
(To be clear, when I say web root, I mean whatever the DocumentRoot directive in your virtual host config of your apache config file is set to.)
Anyways. Assuming DocumentRoot is /home/<user>/wiki.rehman.website/w (i.e. the directory /home/<user>/wiki.rehman.website/ corresponds with https://wiki.rehman.website/ ), and mediawiki is installed in /home/<user>/wiki.rehman.website/w, the correct config would be
in /home/<user>/wiki.rehman.website/w/.htaccess
RewriteEngine On # main rewrite rule RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L] # Redirect / to Main Page RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]
In /home/<user>/wiki.rehman.website/w/LocalSettings.php
$wgScriptPath = ""; $wgArticlePath = "/wiki/$1";
Thanks for the detailed reply @Bawolff. I did also try exactly as you said, but it too did not work. From what I understand, Short URL would not work properly when installed on document root.
I just finished reinstalling fresh again, this time as follows:
- Server DocumentRoot configured as
home/<user>/wiki.rehman.website/root/
- MediaWiki installed in the subdirectory
/w
(wiki.rehman.website/w/index.php
)
In the above scenario, Manual:Short URL/Apache#Simple instructions works exactly as it is mentioned.
There is a problem using page title in URL: it doesn't work well for non-latim based alphabets. For example this is how cyrillic link look like: https://ru.wikisource.org/wiki/%D0%9C%D0%B8%D1%85%D0%B0%D0%B8%D0%BB_%D0%95%D0%B2%D0%B3%D1%80%D0%B0%D1%84%D0%BE%D0%B2%D0%B8%D1%87_%D0%A1%D0%B0%D0%BB%D1%82%D1%8B%D0%BA%D0%BE%D0%B2-%D0%A9%D0%B5%D0%B4%D1%80%D0%B8%D0%BD
Is it possible to use IDs of pages in URL instead of titles?
The only idea I can think of would be to install Extension:ShortUrl and use JavaScript in the frontend to replace the long URL with the short URL in the user's browser. The Bengali Wikipedia offers short links using this plugin, where https://bn.wikipedia.org/s/qvm redirects to the full title.
webite: http://wiki.tumblenet.tk
I folloed the short url builder and i get this;
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@wiki.tumblenet.tk and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
my htaccess and local settigs.php
.htaccess
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2 [L,QSA,B]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
Localsettings.php
<?php
# This file was automatically generated by the MediaWiki 1.26.3
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;
$wgSitename = "Tumble Netpedia";
$wgMetaNamespace = "Tumble_Netpedia";
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
## The protocol and server name to use in fully-qualified URLs
$wgServer = "http://wiki.tumblenet.tk";
$wgScriptExtension = ".php";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
## The URL path to the logo. Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo = "http://wiki.tumblenet.tk/w/wiki-logos/logo-normal.png";
## UPO means: this is also a user preference option
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgEmergencyContact = "noreply@wiki.tumblenet.tk";
$wgPasswordSender = "noreply@wiki.tumblenet.tk";
$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "###";
$wgDBuser = "###*";
$wgDBpassword = "###";
# MySQL specific settings
$wgDBprefix = "mediawiki_";
# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
# Experimental charset support for MySQL 5.0.
$wgDBmysql5 = false;
## Shared memory settings
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = array();
## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgGenerateThumbnailOnParse = false;
#$wgUseImageMagick = true;
#$wgImageMagickConvertCommand = "/usr/bin/convert";
# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = true;
## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "en_US.utf8";
## If you want to use image uploads under safe mode,
## create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment
## this, if it's not already uncommented:
#$wgHashedUploadDirectory = false;
## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";
# Site language code, should be one of the list in ./languages/Names.php
$wgLanguageCode = "en-gb";
$wgSecretKey = "###";
# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "###";
## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "https://creativecommons.org/licenses/by-sa/3.0/";
$wgRightsText = "Creative Commons Attribution-ShareAlike";
$wgRightsIcon = "$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png";
# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "";
## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";
# Enabled skins.
# The following skins were automatically enabled:
wfLoadSkin( 'CologneBlue' );
wfLoadSkin( 'Modern' );
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Vector' );
# Enabled Extensions. Most extensions are enabled by including the base extension file here
# but check specific extension documentation for more details
# The following extensions were automatically enabled:
wfLoadExtension( 'Cite' );
wfLoadExtension( 'CiteThisPage' );
wfLoadExtension( 'ConfirmEdit' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'ImageMap' );
wfLoadExtension( 'InputBox' );
wfLoadExtension( 'Interwiki' );
wfLoadExtension( 'LocalisationUpdate' );
wfLoadExtension( 'Nuke' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'PdfHandler' );
wfLoadExtension( 'Poem' );
wfLoadExtension( 'Renameuser' );
wfLoadExtension( 'SpamBlacklist' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'TitleBlacklist' );
wfLoadExtension( 'WikiEditor' );
# End of automatically generated settings.
# Add more configuration options below.
// Define constants for Portal namespaces.
define("NS_PORTAL", 3000); // This MUST be even.
define("NS_PORTAL_TALK", 3001); // This MUST be the following odd integer.
// Add namespaces.
$wgExtraNamespaces[NS_PORTAL] = "Portal";
$wgExtraNamespaces[NS_PORTAL_TALK] = "Portal_talk"; // Note underscores in the namespace name.
# Extension:Scribunto
require_once "$IP/extensions/Scribunto/Scribunto.php";
$wgScribuntoDefaultEngine = 'luastandalone';
$wgScribuntoUseGeSHi = true;
$wgScribuntoUseCodeEditor = true;
# Extension:CodeEditor
wfLoadExtension( 'CodeEditor' );
# Extension:TemplateData
wfLoadExtension( 'TemplateData' );
// Set this to true to enable the TemplateData GUI editor
$wgTemplateDataUseGUI = false;
You should look at the server's error log, as the error page displays, since that page doesn't give details about the cause of the error. It may be a bad syntax or incompatible setting in .htaccess or LocalSettings.php
hi,
my site previously had the following structure
http://example.de/Main_Page
Now I have changed it with Localsettings und htaccess to the following structure
http://example.de/wiki/Main_Page
htaccess configuration:
# Enable the rewrite engine
RewriteEngine On
# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
Localsettings
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
Now I want all my Pages of the old structure to be redirected to the new one. But do not know how to do that.
34/5000
all pages with the old structure
Now I would like for all sides a forwarding to the new path
Example:
http://example.de/Page1 should redirected to http://example.de/wiki/Page1
http://example.de/Page2 should redirected to http://example.de/wiki/Page2
http://example.de/Page3 should redirected to http://example.de/wiki/Page3
etc.....
Also, the paths of the pictures should be redirected. Previously, I had the following structure
"http://example.de/images", but now I would like to have a redirection for all my images to the new Path "http://example.de/w/images".
can someone help?
***Now I want all my pages with the old structure to be redirected to the new one.
Example:
http://example.de/Page1 should redirected to http://example.de/wiki/Page1
http://example.de/Page2 should redirected to http://example.de/wiki/Page2
http://example.de/Page3 should redirected to http://example.de/wiki/Page3
etc.....
Also, the paths of the pictures should be redirected. Previously, I had the following structure
"http://example.de/images", but now I would like to have a redirection for all my images to the new Path "http://example.de/w/images".
can someone help?