This page used the Structured Discussions extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made.
Latest comment: 12 years ago2 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
"However please note that there is no real valid reason to configure your wiki this way."
The phrasing is somewhat confusing, but it isn't wrong. What is important is that your virtual article path does not conflict with the script path. The default configuration has no separate article path, so there is no conflict.
Now, if you decide to set up Short URLs, then you set up rewrite rules. In that case it is important that your shortcut does not match the script path:
# Short URLs: WRONG
Script path: /w
Article path: /w/$1
Here there is a conflict because /w/something can be an article or a file.
# Short URLs: RIGHT
Script path: /w
Article path: /wiki/$1
Here there is no conflict (this is also how Wikipedia.org and MediaWiki.org are configured). /w/something is a script, /wiki/something is an article. Krinkle (talk) 15:38, 18 January 2013 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 11 years ago2 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Latest comment: 11 years ago6 comments2 people in discussion
RESOLVED
always use the recommended way
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
In the description of the changes in httpd.conf, the following sequence of characters appear:
DOCUMENT_ROOT
Is it somehow related with variable $wg used in the LocalSetting.php?
Should this sequence of characters be replaced to something specific for my computer or it should be copypasted as is?
As I understand, in order to provide the Short URL, the following lines should be added to httpd.conf
## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
# 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]
P.S.: 'DOCUMENT_ROOT' is
The document root directory under which the current script is executing, as defined in the server's configuration file. Domitori (talk) 12:40, 12 April 2013 (UTC)Reply
%{DOCUMENT_ROOT} is an Apache variable that automatically contains whatever the DocumentRoot is set to, leave it alone. It's not related to any of the LocalSettings.php config variables.
%{DOCUMENT_ROOT} isn't assigned in any file. It's natively handled by Apache itself. You won't see where it's handled unless you go looking at Apache's pre-compiled C source code.
I can't really help you figure out what file you should use, different operating system distributions put it in different locations. You should probably ask whoever setup the server for you or perhaps just use .htaccess files instead. Daniel Friesen (Dantman) (talk) 22:47, 12 April 2013 (UTC)Reply
Thank you Daniel. The configuration of .htaccess does not look simpler, so, I still try to follow the suggestion
The recommended way to setup short URLs in Apache is by editing the Apache config files.
I think, I should edit httpd.conf ; it is first file mentioned in the instruction, that I find in my server.
Perhaps, I am not at the shared host, and, perhaps, I do not use a virtual host. (I am investigating the case.)
Also, I do not know, whether the restarting Apache is somehow related to the restarting of server or not.
I think, first, I should learn to restart the Apache. (Over-vice, if a crash, I shall not now, is it due to the error at the editing of httpd.conf or due to some error at the restarting procedure.) Domitori (talk) 05:40, 13 April 2013 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 11 years ago13 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I am a bit confused:
I want to use /wiki/Page_title
I have root access (on a cloud server running Ubuntu 13.04) and would prefer NOT to use an .htaccess file
However when I put my domain name into shorturls.redwerks.org it will only generate the code for a .htaccess file.
Therefore, I ignore the auto-generated code and:
go to edit the /etc/apache2/sites-available/default file.
I am reminded Don't forget to enable overrides by AllowOverride All. It is disabled by default in Ubuntu 12.04 and Ubuntu 12.10. Nothing about Ubuntu 13:04. I assume this is referring to /etc/apache2/sites-available/default but AllowOverride All it appears several times there. Do I change them all or just one? I change them all, and save.
For the shorturl tool you can scroll down and open up the "Detected settings" section. Apache has a sub-section with an option called "I have root access on my server, plese output apache config." you can select that and submit to get Apache config rather than .htaccess config.
You can actually just use the same rules you put in .htaccess inside of your server config. The RewriteRules are the same. Alias based rules are not recommended anymore.
...and I have the instruction: "Apache config: This configuration is meant to go the same block as whatever VirtualHost or other directive you have your wiki's DocumentRoot, ServerName, etc... already defined in." I presume this means I have to put the code into one of the blocks in etc/mediawiki/apache.conf which, in my case, looks like this:
# Uncomment this to add an alias.
# This does not work properly with virtual hosts..
Alias /mediawiki /var/lib/mediawiki
<Directory /var/lib/mediawiki/>
Options +FollowSymLinks
AllowOverride None
order allow,deny
allow from all
</Directory>
# some directories must be protected
<Directory /var/lib/mediawiki/config>
Options -FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/lib/mediawiki/upload>
Options -FollowSymLinks
AllowOverride None
</Directory>
So I paste in the Redwerks code into the first directory block (because I am not sure whatelse to do) and go to etc/mediawiki/LocalSettings.php and add the extra lines but I find that when I go back to my wiki I have correctly formed short urls http://www.mydomain.com/wiki/Main_Page but I now get a 404 Not Found page error.
Installing MediaWiki with an OS package like you have is generally a really bad idea. You are going to run into bugs and issues that you wouldn't usually run into. Like this one.
But anyways, the issues:
%{DOCUMENT_ROOT}/mediawiki doesn't exist since mediawiki is an alias for /var/lib/mediawiki/.
Don't put the RewriteRules inside that directory block. That directory block only applies to things in /mediawiki, so rules that apply to /wiki/ which is relative to the root won't be applied at all.
There are three things you can do:
Reinstall files from source the normal way
or, swap %{DOCUMENT_ROOT}/mediawiki for /var/lib/mediawiki
OK: "Alias based rules are not recommended anymore." So I remove the Redwerks code from etc/mediawiki/apache.conf and add it to etc/apache2/sites-enabled/default.
When I restart apache:
...# apache2ctl restart
Syntax error on line 8 of /etc/apache2/sites-enabled/000-default:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not
Latest comment: 9 years ago7 comments3 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
How do I redirect queries like .../w/index.php?title=penguin to .../nationstates/penguin, like what Wikipedia does? I currently have RewriteRule ^/?nationstates(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L] in .htaccess and I use Apache. Thanks. Marianian (talk) 06:51, 28 September 2013 (UTC)Reply
The short URLs (.../nationstates/Penguin) are working but so does (.../w/index.php?title=Penguin). When using the long version, the address bar doesn't change automatically to the short version (as Wikipedia does). Sorry about being new to this mod by I am trying to get all users to use the Short URL as it is cleaner. Marianian (talk) 01:10, 29 September 2013 (UTC)Reply
That's the intended behaviour of short URLs. If the /index.php url is perfect then no redirection is performed. Wikipedia doesn't redirect /w/index.php either.
The only time that redirection is performed is when the title param/article path text doesn't match the normalized form of the title and there is no additional query.
The normalized form of "penguin" is "Penguin" so when the case doesn't match the proper one MW does a redirect. Coincidentally sending you from /index.php to /wiki because the redirection itself is done using the Title's url returning methods.
So, 2 years later Wikipedia is actually redirecting to short URL's if you give it a long one (which includes the index.php part). I've been looking everywhere for how to set it up but to no avail. I think this is handled inside Mediawiki because it understands the difference between ...&action=view and ...&action=edit. MushToLearn (talk) 01:38, 29 August 2015 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 11 years ago2 comments2 people in discussion
RESOLVED
forgot a semi-colon
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I need some guidance on using short URL's with favicons? I've Google'd the problem a fair bit and tried the following with no success. I'm running Mediawiki on my own virtual server and am editing the /etc/apache2/sites-available/default file.
I've tried the following:
Adding RewriteCond %{REQUEST_URI} !^/favicon.ico before the index.php RewriteRule.
Adding RewriteRule .*\.ico$ – [L] before the index.php RewriteRule.
The wiki install is standard. Everything is at /etc/w/ with a symbolic link to /var/www. My apache default file is configured to follow symbolic links.
Here are the relevant lines in my LocalSettings.php file:
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1"
$wgFavicon = "$wgScriptPath/favicon.ico"
If I comment out the favicon variable in the LocalSettings.php file the site runs flawlessly. If I leave the Favicon variable active I immediately get a 500 Internal Server Error.
EDIT: I looked in my Apache error.log and found the problem. Here's the error:
[Mon Mar 03 10:25:51 2014] [error] File does not exist: /var/www/favicon.ico
Now, why would apache be looking to /var/www/ for the favicon when I have set the location as $wgScriptPath/favicon.ico in LocalSettings.php? 199.27.232.6217:21, 3 March 2014 (UTC)Reply
This is the OP. After scouring the log files I found that the error was due to not adding the semi-colon after:
Latest comment: 10 years ago8 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
My media wiki installation is located at /w on shared server with no root access. mod_rewrite is active, Apache 2.0 Handler.
I have configured my .htaccess (located in /w/) file with the help of http://shorturls.redwerks.org so it reads like this
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]
The document name you requested (/wiki/Drehorte) could not be found on this server. However, we found documents with names similar to the one you requested.
Available documents:
/wiki.phtml/Drehorte (common basename)
I guess there is still something wrong with my .htaccess but as you can probably guess by using the redwerks tools I have no idea what exactly these rule (and I'm) are doing and why it won't work.
My hosting support told me to have the domain point to an extra folder with a .htaccess file (and only there) which contains
I will be forever grateful for any help since unfortunately I do not understand the logics of regular expressions, I have tried for days now to fix this with manuals around the web, but no luck. CayceP (talk) 14:28, 26 June 2014 (UTC)Reply
I don't know where the "Multiple Choices" stuff is coming from.
But the .htaccess for your site should be in the root, not in /w, because it needs to rewrite things from /wiki/ which is not under /w, so it needs to be /.htaccess not /w/.htaccess. Daniel Friesen (Dantman) (talk) 07:23, 28 June 2014 (UTC)Reply
I know/suspected that but for some strange reason, the with .htaccess in root the wiki was/s not working correctly (error 404 or the common basename and internal errors although the settings seem correct). The one in /w (or /wiki) worked.
Of course I deactivated the .htaccess in /w/ and /wiki/ while trying around).
Initially I accidentally installed the wiki in /wiki not /w which used to work so far (only the skins weren't working) but now by trying around and changing back and forth with those friggin .htaccess now some images are not longer displayed and the skins are not working even when I restore the original working .htaccess *argg*.
so with wiki installation in /w/ active (and the initial wiki in /wiki/ deactivated) and .htaccess in root (the wikis Main pages seem to work, but upon calling articles, the common base name error appears)
Oh, I'm so sorry. I was trying to re-established the status quo (the wiki that was working but the skins which has been installed in the wrong directory [/wiki]). It's now switched it back to problematic installation and I won't touch it for the time being. (w/.api.php) is now working).
Sorry, I had to reverse to the working installation located in /wiki/ for the time being so the site is at least usable. Thanks for trying to help, though. CayceP (talk) 14:13, 2 July 2014 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 10 years ago2 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Latest comment: 10 years ago2 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
(Massive 403 "Forbidden" error that fills the screen)
If it helps, I'm hosting it on my own computer using WAMP, and a DNS host record via Namecheap.com. However, using only my IP gives me the same error.
On a side note, the http://shorturls.redwerks.org/ website can easily be made more informative. An example URL near the form would tell us how the URL might look and what we need to include. Also, you're playing with fire when you write three large paragraphs of text instead of short, concise instructions in a numbered list. The same can be said of the Manual:Short_URL/Apache page. It's really long and confusing. GregariousJB (talk) 21:34, 15 September 2014 (UTC)Reply
Your site isn't available at the moment so I can't debug the errors.
The first error typically happens when your site outputs PHP errors/notices due to something broken in an extension or your settings file.
Latest comment: 10 years ago2 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I have multiple MW installations on a single Apache Webserver. The steps given here mention the short URLs considering that there is only one MW installation per Webserver.
Anyone got an idea as to what to do do to make multiple clean URLs on multiple installations but on same Webserver.
You won't need to do anything special at all. .htaccess files only need to be high enough up in the path that they are above both the /index.php and /wiki/ paths. So you'll have /departmentA/.htaccess and /departmentB/.htaccess and wont need to do anything.
Then the wiki will share a common root since for a .htaccess to apply to both /departmentA_wiki and /departmentA it would need to be in the root .htaccess. But it won't be too hard, the rules that setup your short urls don't intersect so all you'll do is put the config you get for both wiki into the same /.htaccess file.
The only tweaks you'll want to make to what you get are that you'll only need one RewriteEngine On and you might want to remove the RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L] line that redirects the site root to the wiki's mainpage. Daniel Friesen (Dantman) (talk) 21:33, 18 September 2014 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
What does it mean when it says: "The MediaWiki directory is located at: /w" ?
Latest comment: 10 years ago2 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I have a question on the very first requirement in this guide.
Quote: "The MediaWiki directory is located at: /w"
What does this mean?
The mediawiki tar has been extracted in to /var/lib/mediawiki, and then a symlink named "w" has been created in /var/www/html/ to point to /var/lib/mediawiki ?
The mediawiki tar has been extracted in to /w . I.e. a directory called /w on the root of the server filesystem ?
There is no physical "w" directory on in the filesystem. There is an alias in one of the Apache config files (which one and in what section?) of the form: "Alias /w /var/lib/mediawiki"
Or something else?
Can this be clarified please, perhaps with an example of every place where /w is referenced so that any attempt to change it will get all of the occurrences? Thanks. Gareth.randall (talk) 08:34, 10 December 2014 (UTC)Reply
Something else: It means the tarball has been extracted into the folder /w. Later down the page we expect that this folder is located directly inside the webroot. E.g. if your webroot is /var/www, then /w would have to be /var/www/w/. 88.130.88.18922:58, 18 December 2014 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Alias basically turns /wiki/Foo into /w/index.php/Foo rather than just telling Apache to load index.php. I can't remember the specific things that ended up different but it isn't ideal.
If you google ''alias vs rewrite" you will find that apache recommends alias over rewrite. Mediawiki is special, butb I did not read of any problems with alias. Do you?
Also what do you mean by "just telling Apache to load index.php", to me it looks like alias and rewrite are both replacing one with the other, dont they? Berot3 (talk) 16:43, 26 January 2021 (UTC)Reply
So after some more testing I think it's worth mentioning in the Manual, that there is an alternative to rewrite with alias.
In the Manual it only says that you can try using Alias if rewrite is not working in some cases. But I think this should be it's own part:
Note: this has to be done by altering the httpd.conf.
I think I forgot to mention something important. the apache-config is probably different when using virtual hosts. the code above is just for using with prefix and without vhost. Berot3 (talk) 17:40, 11 May 2021 (UTC)Reply
Never applies the rules even when AllowOverride is on.
Latest comment: 8 years ago6 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Centos 7, Apache 2.4.6
So, I am trying to short URL like this:
http://mywiki.com/index.php/article</pre>
to
<pre>http://mywiki.com/wiki/article</pre>
[Edit: I changed this from mywiki.com/article to mywiki.com/wiki/article. Sorry, I originally wrote this after doing command line for about 8 hours straight.]
I have mod_rewrite enabled:
<pre>grep -i LoadModule /etc/httpd/conf/httpd.conf | grep rewrite</pre>
gives
<pre>LoadModule rewrite_module modules/mod_rewrite.so</pre>
I have a symbolic link called "fts" that points to the root folder of the wiki documents.
I go to my root folder of my wiki documents:
<pre>cd /var/www/html/mediawiki-1.24.1
sudo vim .htaccess</pre>
and then I create this .htaccess file
<pre>## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
# Enable the rewrite engine
RewriteEngine On
# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/fts/index.php [L]
# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/fts/index.php [L]</pre>
Then I load up my wiki and nothing is different. So, I go back to to httpd.conf and make sure AllowOverrides All is on:
<pre>grep -i AllowOverride /etc/httpd/conf/httpd.conf</pre>
gives
<pre>AllowOverride None
AllowOverride All <--- this is the <Directory "/var/www/html"> section one
AllowOverride None
AllowOverride None</pre>
What's up here? I can't figure out why nothing is going on. I'm restarting httpd every time I do an edit to anything. Nathan in Oregon 23:24, 1 February 2015 (UTC)
:Note that ''only'' adding stuff to apache config files doesn't automagically make MediaWiki aware of the new URL scheme. You should change $wgArticlePath accordingly so MediaWiki generates URLs following that scheme.
:You said you want your URLS to be http://mywiki.com/article, but you set up rules for URLs like http://mywiki.com/wiki/article:
:<code> RewriteRule ^/?'''wiki'''(/.*)?$ %{DOCUMENT_ROOT}/fts/index.php [L]</code>
:Also note that the URL scheme you propose is not recommended, since there are more paths under your mywiki.com domain that shouldn't be treated as wiki pages. Looks like you're missing reading/understanding some important parts of the manual.
:And I don't understand why do you have a fts link pointing to the parent folder. That's really awkward. [[User:Ciencia Al Poder|Ciencia Al Poder]] ([[User talk:Ciencia Al Poder|talk]]) 20:46, 2 February 2015 (UTC)
::test [[Special:Contributions/67.171.179.59|67.171.179.59]] 04:08, 4 February 2015 (UTC)
{{Archive bottom}}
== Cann't get this extension working ==
{{Archive top|result=probably not relevant anymore|status=resolved}}
Hi,
I am not able to get this extension working. All my efforts either ends up in 400 not found or Bad Request.
what I am doing is, added following in my LocalSettings.php
<syntaxhighlight lang="php" strict="">
require_once("$IP/extensions/ShortLinks/ShortLinks.php");
$wgArticlePath = "wiki/$1";
$wgUsePathInfo = false;
</syntaxhighlight>
Added following in httpd.conf file:
<syntaxhighlight lang="php" strict="">
LoadModule rewrite_module modules/mod_rewrite.so
<syntaxhighlight lang="php" strict>
<VirtualHost IP:port no>
RewriteEngine On
DocumentRoot "/path/to/apache/webroot/"
<Directory /path/to/apache/webroot/>
AllowOverride All
Require all granted
</Directory>
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/Mediawiki-1.23/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
</VirtualHost>
</syntaxhighlight>
Value for following variables are:
<syntaxhighlight lang="php" strict="">
$wgArticlePath = "/wiki/$1";
$wgScriptPath = "/Mediawiki-1.23";
</syntaxhighlight>
What I am expecting is, that in the browser I should get the URL as "http://IP/Mediawiki-1.23/ " (w/o the index.php) and also it should be able to navigate within the wiki w/o having the index.php in the URL.
I am trying this on Apache 2.4 and PHP 5.4. Please suggest, how can I get this working? [[User:Solanki|Solanki]] ([[User talk:Solanki|talk]]) 10:42, 3 February 2015 (UTC)
:<code>$wgArticlePath = "wiki/$1";</code> is wrong, it must start with /.
:Besides that it doesn't look like you have followed the guide at all.
:The -f and -d don't apply when doing /wiki/$1 urls and mediawiki is in a separate folder and they're in the wrong spot.
:And there is no mention anywhere of <code>RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]</code>, which is likely intercepting any url belonging to your wiki and sending it somewhere else. [[User:Dantman|Daniel Friesen (Dantman)]] ([[User talk:Dantman|talk]]) 10:49, 3 February 2015 (UTC)
::Actually, when I wasn't able to make it work, I took reference from many sources and clubbed too many parameters in the hope that it would work.
::Apparently, now it works, Thanks to you.
::The only thing I am wondering now, is how to get it working for every links within the wiki like the way it is working for main page. [[User:Solanki|Solanki]] ([[User talk:Solanki|talk]]) 14:58, 3 February 2015 (UTC)
:::If it doesn't work outside the main page, are you sure $wgArticlePath is set right? [[User:Dantman|Daniel Friesen (Dantman)]] ([[User talk:Dantman|talk]]) 12:34, 4 February 2015 (UTC)
::::I have set: $wgArticlePath = "/wiki/$1";
::::What I am trying to say is, if u crate a new page, then the URL for that page must behave in the same manner, but here it isn't.
::::So, Is there any thing else I need to take care of? [[User:Solanki|Solanki]] ([[User talk:Solanki|talk]]) 07:19, 5 February 2015 (UTC)
{{Archive bottom}}
== Some pages have links (on buttons) that do not obey this setup ==
{{Archive top|result="MediaWiki's short urls only apply to simple page views."|status=resolved}}
I achieved what was promised - short URL's, for most pages.
However, there are pages that generate URL's to other pages that do not respect this setup.
For example, after setting it all up, I tried to uplaod a sample picture and then delete it.
"Delete" link on that page is generated to use NOT pretty version of the url, ie:
/w/index.php?action-delete&...
Same for many other links that are action "buttons":
Go button on running queires on secial pages,
link to view current user account - all have non-magled, un-pretty url in them;
My guess, php code behind those pages does not use $wgArticlePath variable, but instead uses raw $wgScriptPath, which causes them to generate links against this setup;
Also, upload page actions do not fall under posted rewrite rules. uploaded images were not always showing up.
Had to add another rule to rewrite prefix of urls generated with $wgUploadDirectory [[Special:Contributions/68.174.167.16|68.174.167.16]] 01:20, 22 June 2015 (UTC)
:MediaWiki's short urls only apply to simple page views. Most URLs with queries in them point to index.php so that they can be included in <code>robots.txt</code>. Some &action= urls can be made to use a different short url if you configure $wgActionPaths for them. [[User:Dantman|Daniel Friesen (Dantman)]] ([[User talk:Dantman|talk]]) 02:30, 22 June 2015 (UTC)
{{Archive bottom}}
== .htaccess: Rewriting /$IP to a subdomain ==
{{Archive top|result=done|status=resolved}}
I am on a shared Apache host. Relative to my folder's root, MediaWiki is installed at /connections. I would like to rewrite it to connections.mydomain.com. I couldn't find any way to set up this URL scheme in the MediaWiki ShortURL Builder at Redwerks, so I set up the subdomain through my web host. I then tried the tool again, which gave me the following:
<syntaxhighlight lang="php" strict="">
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ %{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]
</syntaxhighlight>
<syntaxhighlight lang="php" strict="">
$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/$1";
$wgUsePathInfo = true;
$wgEnableUploads = true;
$wgGenerateThumbnailOnParse = false;
</syntaxhighlight>
I put these in an .htaccess file at /connections, but then got 500 errors. What am I doing wrong? [[User:Jkmartindale|James Martindale]] ([[User talk:Jkmartindale|talk]]) 05:15, 22 February 2016 (UTC)
:I don't see any obvious syntax error so this may be a misconfiguration on the server that doesn't allow defining rewrite rules on .htaccess. [http://stackoverflow.com/a/15850426 See this SO answer] for example.
:You may have an error log for your subdomain to look a detailed error message. [[User:Ciencia Al Poder|Ciencia Al Poder]] ([[User talk:Ciencia Al Poder|talk]]) 13:05, 22 February 2016 (UTC)
:I currently use RewriteEngine to force www.domain.com to domain.com, so I think I it works within .htaccess and it may just be the way my host configures the subdomain. Is there a way to catch the subdomain at domain.com and rewrite it to /connections without using my web host?
:I'll ask my host for the error log. [[User:Jkmartindale|James Martindale]] ([[User talk:Jkmartindale|talk]]) 14:59, 22 February 2016 (UTC)
{{Archive bottom}}
== Short URLs not working ==
{{Archive top|result=seems resolved|status=resolved}}
I went to shorturls.redwerks.org and typed the URL of wkse. '''Encountered invalid XML while trying to find the API''' shows up so I try to do it myself.
I followed the manual and this is not working:
<pre>RewriteEngine On
RewriteBase /wkse
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]
Without knowing what's your expected URL structure, it's hard to tell where's the error, since we can't know where in the document root your wiki resides, how your short URLs should look, etc
From what you post I see a discrepancy: You have RewriteBase /wkse, so I assume your short URL should look like yourdomain.com/wkse/Pagename, but you have $wgArticlePath = "/$1"; which will be interpreted as yourdomain.com/Pagename Ciencia Al Poder (talk) 10:21, 23 March 2016 (UTC)Reply
The RewriteBase is needed because 000webhost doesn't use actual sub(sub)domains, the contents of wkse.luisantonimperial.net23.net reside in luisantonimperial.net23.net/wkse.
The URL structure you propose will be problematic, as already warned on this page.
Besides that, your server doesn't seem to be properly configured, or you don't seem to have an index.php file on the document root of the server, since accessing it gives a straight 404 error page. Ciencia Al Poder (talk) 20:50, 23 March 2016 (UTC)Reply
That may indicate your hosting doesn't support URL rewriting, since those rewrite rules doesn't match /wkse and shouldn't have any effect. Apache just errors out if it finds configuration settings that doesn't understand in .htaccess Ciencia Al Poder (talk) 11:27, 27 March 2016 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 8 years ago2 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Noticed that mediawiki.org and wikipedia.org have complete redirect: https://www.mediawiki.org/w/index.php?title=Article goes directly to https://www.mediawiki.org/wiki/Article
On a normal wiki with rewrite rules that doesn't happen.
Latest comment: 3 years ago3 comments3 people in discussion
didn't reply
My problem is that both none HTTPS requests and requests with WWW redirects to main page, whitch is fine when the requested url is the root domain, but not if the request is an article, special page etc.
Probably that you need to put the http to https redirect at the start rather than the end of the file - I haven't studied how .htaccess works - but if https is working fine then if you convert the http to https right at the start, the rest of the url unchanged, then as it flows through it should work just as if the user had entered an https url originally. Robertinventor (talk) 16:52, 1 October 2018 (UTC)Reply
Make sure the 'rewrite' module is on first - had me stuck for ages.... it is off by default on Apache
Latest comment: 4 years ago2 comments2 people in discussion
RESOLVED
further explanation to a paragraph of the article
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
This makes absolutely no sense:
"Note: If you are using a script path and article path that match such as /mywiki/index.php and /mywiki/Article you will also need to use the same two RewriteCond lines on your RewriteRule. However please note that there is no real valid reason to configure your wiki this way. If your article path is already a subdirectory you should just move your wiki's script path to another directory. Such as /w/index.php and /mywiki/Article or /my/index.php and /mywiki/Article."
I agree, not a easy subject. I'll try my best. With other words:
if you the folder where the actual index.php is (under htdocs for example) AND you want the subdirectory(/mywiki)-path to be the same (like http://domain.tld/mywiki), than you need additonal RewriteRules.
But as it states next "However please note that there is no real valid reason to configure your wiki this way", you shouldnt really do it like that. It is simply not recommendet and also there are no RewriteRules that I know of that could solve this.
In the next sentence after that, it tells what the recommended way is: name the folder "w" where the actual mediawiki is stored and that's it! Berot3 (talk) 16:23, 26 January 2021 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 7 years ago1 comment1 person in discussion
RESOLVED
nevermind it fixed itself
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Latest comment: 6 years ago7 comments3 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I've used the Redwerks tool to create the short url to "/wiki/$1", with the wiki being stored in "/public_html/mediawiki/w" (shared host). However, I still want to use the standard URL to reach a normal site and only "www.[domain].com/wiki" to lead to the wiki. But since the .htaccess file for this configuration has to be placed in /public_html/, it always redirects. What will have to be changed? 145.44.77.224 (talk) 09:32, 24 May 2018 (UTC)Reply
Is the domain specified in $wgServer in yourLocalSettings.php ? If so: For my wiki (also on a shared host) it only works correct if I put the .htaccesss in the w/ folder (which one shouldn't do according to this website but yet it works). Maybe give that a try? CayceP (talk) 11:06, 24 May 2018 (UTC)Reply
Unfortunately, that doesn't work, regardless of where I place the file or what the settings are in LocalSettings. Yes, the domain is specified. 145.44.77.224 (talk) 11:39, 24 May 2018 (UTC)Reply
That is odd. Does it change anything if you temporarily rename the .htaccess to no.htaccess and put your domain name in $wgServer? This should have an effect (either that you get a 500 error or it you get an ambiguous name message etc), if not than there is probably some other config file or .htaccess on work and your .htaccess has no effect what so ever at the moment. CayceP (talk) 11:55, 24 May 2018 (UTC)Reply
If I do anything other than what I have (e.g. move .htaccess anywhere other then /public_html/, change the ScriptPath, etc.) I get a 404 error.
Latest comment: 5 years ago9 comments3 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
CentOS7
MediaWiki 1.30.0
PHP 7.1.16 (apache2handler)
MariaDB 5.5.56-MariaDB
ICU 50.1.2
I have a mediawiki running on a directory, /mw/ and it generates the /mw/index.php/Article
I just want to remove the index.php section.
I have root access and have run Redworks' ShortURL tool. My ShortURL stuff to go into my virtual host is as follows:
Провозился 2 дня. Всё делал как в инструкциях... Переустанавливал вики, специально в подкаталог "w". Всё время выдавало 404, при этом путь менялся как нужно //сайт/wiki/Page_title
Настраивал через .htaccess . В итоге просто нужно .htaccess поместить рядом с папкой "w". До этого был на каталог выше. После всё заработало. 81.163.151.85 (talk) 08:19, 19 April 2019 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 4 years ago2 comments2 people in discussion
RESOLVED
doesnt seem to be a problem anymore
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
On local Windows 10 apache installation %{DOCUMENT_ROOT} on windows creates 403 error.
Latest comment: 6 years ago1 comment1 person in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Change directory to /etc/apache2, edit apache2.conf and under the /var/www change AllowOverride from None to: All
Find the root directory of your webserver, /var/www/html, create a file there called .htaccess and add this:
Latest comment: 5 years ago1 comment1 person in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Followed the instructions for apache - wound up with a mess of formatting and no images.
If this helps others - had to do the following to get it to work:
In the apache2.conf file:
## don't rewrite load.php, api.php, and other php scripts. this got the sidebar and CSS/formatting to work
RewriteRule ^/?wiki.*\.php - [L]
## don't rewrite images/icons in the resources folder. this got icons to work
RewriteRule ^/?wiki/resources - [L]
## rewrite to short url
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L,QSA]
Latest comment: 5 years ago3 comments2 people in discussion
RESOLVED
no response -> closing
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I've followed the Apache instructions to the letter, and just get a 404 error. Straight up doesn't work, and I can't figure out why. Tried putting the rules in 000-default.conf, and mediawiki.conf, and apache2.conf (one at a time), and still nothing. AllowOverride is set to All as well.
Ok so my Wiki is on port 8081 and the VirtualHost was set to 80, so it kind of works now, but when I visit the page it's completely broken, all formatting etc... Have tried everything I can think of, including what's posted below, but nothing... Brickscrap (talk) 17:17, 16 April 2019 (UTC)Reply
Hit F12, open the network tab and reload the page. Look at any error in requests (like HTTP status 404, 400, 500...), and figure out if the URL it's trying to request makes sense. If it makes sense, problem is in apache config. If not, problem is in MediaWiki config. Ciencia Al Poder (talk) 19:13, 16 April 2019 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 4 years ago4 comments3 people in discussion
I've read this, and a wide range of other pages I've found in searches, and still have no clue how to get this ShortURL malarky working. Can somebody help me out? I've installed on localhost, so have root access. But when I try to write these rules and try to restart Apache, I'm met with an error message like below:
AH00526: Syntax error on line 14 of /etc/apache2/sites-enabled/000-default.conf:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Where and exactly how am I suppose to set up this stuff?? Am I supposed to put these lines of RewriteEngine and such inside some type of tags??
Hopefully I'm fiddling with the right file at least, but this is the entirety of it.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
Thank you, that got me a little further. The wiki loads, but the main page looks weird, with the sidebar on the very bottom, and with seemingly no css. If I try http://localhost/wiki/Main_Page, however, there is a Not found error message.
Is there an example somewhere of what these files are supposed to look like when completed and working?
Right now my sites-available .conf holds (with the comments sections removed):
## 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 = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
## The protocol and server name to use in fully-qualified URLs
$wgServer = "http://localhost";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
Latest comment: 5 years ago1 comment1 person in discussion
RESOLVED
seems like nobody is using Lighttpd? closing for now.
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Latest comment: 5 years ago1 comment1 person in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
This Short URL/Apache is great, no doubt, but very confusing instructions and not covering the Windows specific issues with colons.
Latest comment: 4 years ago1 comment1 person in discussion
RESOLVED
I wanted to say thanks, many many thanks
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I'm not sure whether this discussion is just to flag problems, but I wanted to shout a big THANKS to whoever put together the MediaWiki ShortURL Builder. I'm a new MediaWiki user, and not a programmer, so I find these technical bits scary. This builder worked great for me, I wanted to say thanks, many many thanks :) 2001:8003:7CCF:FC00:D408:6760:A405:E1A2 (talk) 00:45, 11 April 2020 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Latest comment: 4 years ago4 comments2 people in discussion
RESOLVED
"I followed the wikimedia style, which has the language wikis as third level domains"
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I just wanted to share my setup of a wikifarm for a multi-language wiki using the same mediawiki installation. After a few days of trial and error I finally seem to have it working, but I didn't use any of the automatically generated scripts that probably wouldn't have worked in my case. In any case this is my setup.
After doing some initial customizations, I took the next step to make a wikifarm for different languages. I copied the "template" database tables of my initial installation to two other database tables with language suffixes ("_en" and "_it")
I created two aliases in my apache vhost file, one for each of the languages that I will currently support: Alias /en/ /var/wikiinstallationpath Alias /it/ /var/wikiinstallationpath
I added logic in the LocalSettings to pick up on the language based on the url "subdirectory": #Let's try to setup a wiki family if ( defined( 'MW_DB' ) ) { // Set $wikiId from the defined constant 'MW_DB' that is set by maintenance scripts. $wikiId = MW_DB; } elseif (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'mywiki.example.com' && substr($_SERVER['REQUEST_URI'], 0, 3) == '/en') { $wikiId = 'en'; } elseif (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'mywiki.example.com' && substr($_SERVER['REQUEST_URI'], 0, 3) == '/it') { $wikiId = 'it'; } else { // Fail gracefully if no value was set to the $wikiId variable, i.e. if no wiki was determined die( 'It was not possible to determine the wiki ID.' ); }
Then I use that wikiID to choose the database: # MySQL specific settings$wgDBprefix = ""; $wgDBname = 'mywiki_' . $wikiId; $wgSharedDB = 'mywiki'; $wgCacheDirectory = "/tmp/mediawiki_".$wikiId."_cache"; $wgUploadDirectory = "$IP/images"; $wgUploadPath = "/images";
Seeing that the language "subdirectories" are aliased to the script path by apache, I figure I can tell mediawiki that my script path is in the language subdirectory (physically non existent, virtually an alias of the real script path): $wgScriptPath = "/$wikiId"; $wgScriptExtension = ".php"; $wgArticlePath = "{$wgScriptPath}/$1"; $wgUsePathInfo = true; $wgServer = "https://mywiki.example.com"; ## The URL path to static resources (images, scripts, etc.) $wgResourceBasePath = $wgScriptPath;
Then I have an .htaccess in my root directory: RewriteEngine On #For the time being we don't use the base hostname, if requested we redirect to the english version RedirectMatch ^/$ /en/ #Let's do Short URLs RewriteCond %{HTTP_HOST} ^(mywiki.example.com)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php [L]
With this current setup, I am successfully serving my pages with short URLs, and the interwiki links are also being generated as short urls. Interwiki links between languages are working nicely too. Now that I've installed the Wikibase extension I just have to figure out how to populate the sites table and use sitelinks to link between my two languages. Lwangaman (talk) 01:33, 16 April 2020 (UTC)Reply
I have actually changed the setup since then. Something eventually went haywire after only a month or so, at first I thought it was spam but maybe it was jobs not being setup correctly. In any case the wiki suddenly stopped being accessible, and I really didn't know where to start to get it up and running again, so I just wiped it out and started all over. This time I followed the wikimedia style, which has the language wikis as third level domains; in my case, the language wikis are fourth level domains. Which in my opinion is a little less accessible than I would like it, but it works. I also made sure to read through everything that has to do with combating spam, and so I set up a few daily jobs to keep the antispam up to date. Wikibase is currently working well, and I have language links between the wikis working nicely. Lwangaman (talk) 17:13, 26 January 2021 (UTC)Reply
Latest comment: 4 years ago2 comments1 person in discussion
RESOLVED
AliasMatch is not really needed because Mediawiki itself is also case-sensitive (like Alias)
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I think this Manual for Apache should maybe be expanded:
using Alias is case-sensitive. Yes, in 97% of the cases this shouldnt be a issue, since everyone is onyl following links or using search.
but since Mediawiki itself is case-insensitive, why should also the alias?
@Jonathan3 I guess you meant my recent questions on the subject in "support desk";
I nicely disagree with that approach ; I when a page is SO undidactic, it kinds of take the spirit out from cooperating, for me at least. In face I already wrote a revised version of the opener of this "guide" and should publish it soon. 2001:44C8:4512:B6D6:A16F:69E9:F0A3:8BD9 (talk) 17:27, 24 May 2021 (UTC)Reply
I'm the anonymous user. I've remembered my user/pass.
For those running debian 10 (probably Ubuntu too) with root access and apache2 do all of this as root:
1. You need to ensure the rewrite module is loaded in apache2 by doing this:
Type:
a2enmod
then when prompted type
rewrite
then press <enter>
2. Next, edit /etc/apache2/sites-available/000-default.conf by typing
This assumes that your mediawiki installation is in the same directory that apache2 is treating as the document root. The document root path is shown in the file you have open. If your index.php file is in that directory then this will work. This will be the case if your URLs are http://mywiki.com/index.php If your URLs look like http://mywiki.com/somefolder/index.php then you will need to modify the above lines to look like this:
If it won't restart you've done something wrong which you need to troubleshoot.
4. Next edit LocalSettings.php by typing
nano /var/www/html/LocalSettings.php
(or whatever path you are using)
Look for the text $wgScriptPath (which will probably be near the top)
As above, if your installation is directly in document root, this will probably read $wgScriptPath = ""; in which case, leave it alone. If you are in a subdirectory like above, it will read something different. Leave it alone anyway.
Polymath you've been a lifesaver. Following your instructions got this done in about 10 seconds. Trying to use the incoherent instructions on the article itself had got me pulling my hair out after failing to make it work for an hour. Jcshy (talk) 06:59, 4 March 2024 (UTC)Reply
I used the script on redwerks.org, running wikipedia on a low-cost shared server. I copied the Apache Config and saved it as a new .htaccess in the directory that the URL should be redirected to, and changed the rows in LocalSetting.php. All done. This was just trial and error and I am happy it worked. 2A02:908:2057:7C80:4012:8145:F350:A140 (talk) 17:56, 8 August 2021 (UTC)Reply
This advice doesn't seem to work anymore. While it rewrites the URL, it causes 404 errors and you can circumvent the rewrite rules by replacing /wiki/ with /index.php/ Met4lGod76 (talk) 00:50, 8 January 2025 (UTC)Reply
This means the rewrite rules aren't applied at all. MediaWiki is acting like they're in place, generating URLs that look pretty, but Apache isn't rewriting them (back to what they should point to). Either you forgot to restart/reload Apache, or your rules are wrong. Ciencia Al Poder (talk) 22:58, 8 January 2025 (UTC)Reply
I manged to get it to work after posting the comment. I don't believe it was an Apache issue, but rather a LocalSettings.php config issue (at least for my instance). Met4lGod76 (talk) 05:17, 10 January 2025 (UTC)Reply
Latest comment: 3 years ago3 comments3 people in discussion
I as a non native English speaker and as a person with a very fundamental and minor knowledge about Apache PCRE, find the guide very complex and unaccessible; passages are too long and I get the feeling of being overwhelmed with data.
I host my website on a shared server and maybe much of what's written here isn't relevant for me.
@Ciencia Al Poder I am a professional developer and consultant in the fields I am in (which MediaWiki is not one of course); I think you should edit the link text to clarify that you explicitly mean to MediaWiki professional development and consulting ; that would be honorable and respected.
I actually want to do the change myself, without hiring anyone but I do think, with all respect to you, that your underestimate a didactance problem with that guide or at least unaware for such didactance problem (a problem in the context of accessing the data to general audience of readers and all types of webmasters; I for example was originally trained as a Drupal webmaster were, as I recall, shorts URLs are on by default (there was a time it just required a module to be installed before making it on by default). Without any desire to be annoying, I still think that the guide should at least wikitionally edited / textually-formatted and yesterday I meant to do this today myself later today and should do so. 2001:44C8:4487:7025:E86D:73EB:DB08:F62F (talk) 09:22, 24 May 2021 (UTC)Reply
Why is the source code of this webpage so messy with translation tags?
Latest comment: 3 years ago1 comment1 person in discussion
Translation should be modular with translations of the main parts of this websites (excluding say "support desk" --- or not excluding it all) to other language websites as similar to how wikipedia enterprises are translated to different language "versions"; otherwise, a total "code spagetti" is caused;
Just to understand what this page is actually about I suggest this revised version of the opener chapter, without even one translation tag (also improving formatting and accessibility):
Wikipedia's short URLs.</translate>
For information on what Short URLs are or to get instructions on configuration for other servers see Manual:Short URL.
These instructions help setup Short URLs on Apache web server software.
The LiteSpeed webserver is Apache compatible and can be configured in relatively the same way.
In this manual we'll recommend/assume the following but remember to use your own paths if they are different.
These following instructions have been included in an automated wizard (requires MediaWiki 1.17 or later) --- shorturls.redwerks.org
If you just want your wiki configured quickly or you find the guide confusing then you may want to try that tool first.
If you do this, please note that you will need to edit or create a .htaccess file.
If you create it anew, please read on to further in this article about where to place the <tvar name=2>.htaccess file, and please note that this file will likely be in a different folder than the other file that will need to be edited (LocalSettings.php), which is in the installation folder.
if you have followed the MediaWiki recommendations). Please also note that using this wizard will not work on firewalled or private wikis, so in these cases, you can still try it out by making your wiki temporarily public by setting $wgGroupPermissions['*']['read'] to true ; remember to change it back to false once you are done.
Otherwise, follow the instructions below.
Server config
Find the right file
The recommended way to set up short URLs in Apache is by editing the Apache config files.
This requires that you have access to the server configuration.
If you are on a shared host, you most likely don't and will need to use a .htaccess file instead.
Using .htaccess files is less efficient and doesn't give you as much control when it comes to fancy setups with multiple domains but they are powerful enough to set up most short url configurations.
LiteSpeed users should use the .htaccess method.
Use the instructions in one of the following two sections, depending on whether you have root access or need to use .htaccess instead.
It was written for an older version of MediaWiki and may not apply to the most recent version. If you have checked or updated this page and found the content to be suitable, please remove this notice. See the talk page for a possible discussion on this.
Latest comment: 3 years ago7 comments4 people in discussion
Every few years I come to this page to implement short URLs, then remember it is horribly confusing and work it out again from scratch. As many people have pointed out, the content seems authoritative but is unlikely to work on any Apache installation. In addition to being incorrect, it is also confusing. So let's start.
One of the first things is to split up Alias from Rewrite techniques into separate sections. Pretty sure the commenter here is correct in saying that Apache recommend Alias over Rewrite although I don't know a reference for that. So the Alias version should probably be listed first.
There are some working or almost-working recipes on this talk page to give us a start.
Thanks Paddy. I could probably make a bigger difference in a few minutes, except I don't know how to edit with the translation tags. Is there a tool that makes that easy? DanShearer (talk) 22:56, 4 February 2022 (UTC)Reply
Alias version should not be listed first, it shouldn't even be here at all. Alias should not be used. I've never seen the reference for Apache recommending Alias over RewriteEngine. But I have a feeling that if it exists at all it's a generic recommendation that is being mis-applied to MediaWiki.
The way Alias works is fundamentally wrong and only works because MediaWiki ignores the bad side effects that Alias introduces.
Proper rewrite rules just rewrite the path to /index.php, without any suffix or query modifications. Basically they just tell Apache, "For this url, run index.php without modifying anything". MediaWiki, not Apache, then reads the whole /wiki/Page path from the raw url in $_SERVER['REQUEST_URI'] and MediaWiki parses out the "Page" page name.
That is not how Alias works. A Alias /wiki /index.php alias actually tells apache to rewrite /wiki/Page to /index.php/Page and then passes "Page" to $_SERVER['PATH_INFO'] expecting you'll use PATH_INFO to get the "Page" title.
If MediaWiki actually used the PATH_INFO that you get by using an Alias instead of a RewriteRule, your wiki's urls could be broken.
The only reason that Alias rewrites work, is because MediaWiki outright ignores the PATH_INFO and takes responsibility for parsing the "Page" title out of the url in REQUEST_URI. i.e. It basically throws the extra stuff Alias does into the trash and demotes it to a basic RewriteEngine rewrite. Daniel Friesen (Dantman) (talk) 22:23, 18 February 2022 (UTC)Reply
Latest comment: 2 years ago1 comment1 person in discussion
Took a while to figure this out, but here are my simpleton's instructions on how to place the re-write directly on Apache instead of using an .htaccess file.
My host is a Virtual Private Network (VPN) which means I have access to CPANEL and WHM
If you do not have access to WHM, this is not for you. Also, these steps are written for Windows users.
NOTE: even though the instructions here say to edit the httpd.conf file directly DO NOT EDIT IT. You will see that at the very bottom of the file it reads:
>> there is an editor function in WHM called "Include editor" I could not figure out how to use this, so I used the following steps instead. I'm sure this will drive knowledgeable users crazy, but this is how I managed to get this stupid rewrite on the server without having to use an .htacces file
>> before starting remove an existing .htaccess file and/or remove the commands for short url that may be in it.
>> we are going to give those instructions directly to the Apache server, which will be included in a file called httpd.confWe are NOT going to edit that file directly.
Step 1.
> Go to CPANEL and open File Manager
>> it should open at the /home/accountname/ directory.
>> if not, click on that directory on the left-hand menu of File Manger.
> click on "+ File" on the top menu (to add a file)
> enter a file name with the extension conf
>> any name works, but must have .conf as extension: as in filename.conf
> select that file and click on "Edit"
>> it will be blank. Add to the very top in plaint text, per instructions on this manual, this code:
> navigate to the httpd.conf file by using "change directory" commands (cd /)
>> the file should be located on this path: /etc/apache2/conf/
>>> first, navigate to the /etc/ folder by typing cd /etc
>>> then navigate to subfolders from there by typing cd directoryname (such as cd apache2 , then cd conf)
Step 3.
> once you are in the directory /etc/apache2/conf/
>> type dir in order to see the contents of that directory
>> you should see listed there the file htttp.conf
>>>> note that the instructions manual here says it may be called apache2.conf
(<<< btw, those instructions are confusing as it indicates that apache2.conf is a directory whereas it is a file name; in my WHM, which is up to date, it is http.conf )
> now we want to read that file:
> type cat http.conf
<<< "cat" command is for "read file"
>> the file contents will spill across the terminal
>> next, highlight the file contents on the screen using your mouse (start from the bottom, hit left click & hold it while scroll up to the beginning of the file, thus highlighting all the contents)
>>> release the left click button, then right click on the selected text and select "copy"
>>> paste the contents into a plain text editor (I use notepad.exe in Windows)
>>> in the text editor, search for your website name
>>> at the bottom the entry for your website/s it will read something like this:
" # To customize this VirtualHost use an include file at the following location
# Include "/etc/apache2/conf.d/userdata/ssl/2_4/accountname/domain/*.conf"
( >> NOTE: if you do not have SSL enabled it that directory will read /std/)
>>> your account name and domain will be already written in that path
> copy that directory path to a new text editor window
Summary so far:
we created a new .conf file using CPANEL at the root of the CPANEL File Manager and wrote the re-write code for short urls.
we identified the correct path to add that file to by reading in WHM terminal, the existing httpd.conf
we copied that path and file name into a text editor.
Step 4.
> type cd to go back to the terminal root directory
>> it looks like root@server.yourprimarydomain.com [~]#
> now we are going to move the file you created in CPANEL to the location that the httpd.conf file told you to place it in order for whm to read and incorporate it into the existing httpd.conf file
> we will use the move command in the terminal: mv
> in your text editor type out the entire move command with the directory paths and file name
>> it should look like this (with your particular account and domain):
<< note the single space after "mv" and "filename.conf" (so it reads mv[SPACE]/path/path/filename.conf[SPACE]/path/path
> hit enter
>> this will move the file to the directory that the httpd.conf file told you corresponds to your website
>> if a file with that name is already there, it will ask you to confirm overwriting it. If so, type YES
Step 5.
> now we need to ask Apache to read the file and recompile the httpd.conf fle
> go to the root directory on the terminal
> type /scripts/ensure_vhost_includes --all-users
>> Apache will recompile the httpd.conf file and tell you if this worked or not
Step 6.
> reboot the server
> use "Gentle reboot"
Test out your site and hopefully you're good to go!
(Sadly this does not fix my issue with Visual Editor, which stopped working after I moved to short urls. That would seem to be a problem for another day) School4schools (talk) 16:26, 6 July 2022 (UTC)Reply
Latest comment: 2 years ago2 comments2 people in discussion
I'm currently running MediaWiki in my personal computer for experimentation purposes (i.e. not planning to use it in production). I'm using Apache in Arch Linux and was able to get the short URL working.
I spent more than 4 hours trying out the solutions mentioned in this documentation. Namely, I created the file .htaccess in multiple locations, edited the options AllowOverride and Options as specified in this page, but none of these ways worked. I decided to give up on Apache and use nginx instead, since there's also documentation on how to get the Short URL for nginx.
However, I then found Short URL/Page title -- Windows & Apache without 403 on Special Pages and was able to find the solution that worked for me. My solution was to add the Rewrite rules under <Directory "/srv/http"> in the file /etc/httpd/conf/httpd.conf. As a complete beginner user of Apache, I'd like to know whether this is recommended or not so that I can add it in this manual since it is not mentioned.
I'll describe what worked for me with the hope that other users find a solution faster than me and don't have to spend as much hours as I spent doing trial and error.
1. First, I wanted my links not to have mediawiki in the URL. That is, the default configuration that is bundled in Arch Linux makes the URL of the articles have the following format.
http://localhost/mediawiki/index.php/Main_Page
but I wanted the pages to exist in
http://localhost/w/index.php/Main_Page
To do this, I changed the first line of /etc/webapps/mediawiki/httpd-mediawiki.conf from Alias /mediawiki "/usr/share/webapps/mediawiki" to Alias /w "/usr/share/webapps/mediawiki"
2. Uncomment the line #LoadModule rewrite_module modules/mod_rewrite.so in the file /etc/httpd/conf/httpd.conf
3. Add the RewriteEngine and RewriteRule instructions under the section <Directory "/srv/http"> in the file /etc/httpd/conf/httpd.conf (see code block below)
4. I then opened /usr/share/webapps/mediawiki/LocalSettings.php to make sure that the variables had the following values. By default, the variable $wgScriptPath already had that value, I just needed to add the line for $wgArticlePath below it.
Can anyone provide some reference to this issue and confirm that it's real and not just speculation added by some users?
The first change targets the VisualEditor user agent but the second asserts that it's just rest.php that needs to not be rewritten. However the RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f line is already supposed to be enough to stop Apache from rewriting rest.php (otherwise it would be rewriting index.php, thumb.php, etc). So this recommendation should be redundant.
I would like to know because if it's a real change we need to make to the recommended Short URL config, then I'd like to update the ShortURL Builder tool. And if it's not actually necessary for VisualEditor to work, then the modification to the page should be reverted. Daniel Friesen (Dantman) (talk) 01:09, 19 December 2022 (UTC)Reply
It works, yet index.php still seen on navigation bar
Latest comment: 1 year ago3 comments2 people in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I followed the process for my local wiki, and it works. Yet, the browser displays the rewritten URL.
Local wiki on my Mac Powerbook:
Scripts located on /Library/WebServer/Documents/wiki
I want to use the name of the wiki site: wikipapers.
After reconfiguring Apache (on httpd.conf) I can write:
http://localhost/wikipapers/Laplace_transform
Apache shows the proper page ... but ... on the navigation bar I still get
just don't take effect, it just asks if I want to create a new page Sites/fan-bay-deep-shelter. The rules do work on the server away from the wiki area. I worry that I'm just changing the URL, but mediawiki is working onm the underlying URI which is not changing Vicarage (talk) 14:06, 25 November 2023 (UTC)Reply
Latest comment: 1 year ago2 comments1 person in discussion
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Did everything according to the guide. Instead of redirecting to main page, accessing my domain (as well as */index.php) displays a page that contents a single "+" symbol and debug outputs if switched on, and nothing else.
Also, CSS broke after fiddling with short urls, now even if I undo everything I still have this error:
Refused to apply style from... because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Latest comment: 2 months ago2 comments2 people in discussion
For some reason, MediaWiki packaged for Debian installs in /usr/share/mediawiki instead of somewhere under /var/www. There is also no file for it in /etc/apache2/sites-available, only in /etc/apache2/conf-available. In which section of which file do the settings go in this case? I am trying to use the root access method and not a .htaccess file, to be clear. WarpedForest (talk) 02:10, 26 October 2024 (UTC)Reply
Files in <code>/etc/apache2/sites-available</code> are just Apache configuration files on how to serve the website using Virtual Hosts. Here's a guide on how to make a <code>.conf</code> file for Apache: <VirtualHost> Directive