Jump to content

Manual talk:Short URL

About this board

READ THIS FIRST IF YOU HAVE A TECHNICAL QUESTION This talk page is not very active. You probably WILL NOT get an answer to your question. It is better to go to MediaWiki_on_IRC where there are live people 24/7, and ask your question there. Odessaukrain 00:26, 9 October 2007 (UTC)

  • HOUSE KEEPING Begin removing nonworking short URL solution links from the main page to the talk page until someone speaks up and says these nonworking Short URL solution links actually work
  • WRITING Using the best portions of the main page as inspiration, begin writing a comprensive and easy to understand manual on how to create a short webpage addess [url].



Uploaded Files return 404 error even though they are uploading

2
Mediabobedit (talkcontribs)

When I upload a image from the Upload Files section to my mediawiki they return a 404 error but when I go to the uploaded files section I can see the thumbnail and click on the File button and it shows the image. If I click on the file name it return the 404 message.

I think the error has to do with Short Url because if I erase /view/ from the link and add index.php?title= it loads the image.

basically my issue is:

mediawiki thinks the files are located at /view/File:filename.png

but they’re really located at index.php?title=File:filename.png

Raymondkkk1 (talkcontribs)

I am having the same issue. Did u fixed that?

Reply to "Uploaded Files return 404 error even though they are uploading"

Server support CGI, but custom added page using Title::newFromText page addresses is not CGI style

1
Epopen (talkcontribs)

Hi All

My server running Mediawiki 1.41 and keep page addresses default.

I saw this manual written as below

MediaWiki's default page addresses looks like these examples:

https://example.org/w/index.php/Page_title (recent versions of MediaWiki, without CGI support)
https://example.org/w/index.php?title=Page_title (recent versions of MediaWiki, with CGI support)

All of pages in my server using "CGI support" addresses.

I added Extension:ContactPage at page footer and modified with reference Manual:Footer using Title::newFromText @ Manual:Title.php as follows


$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {

if ( $key === 'places' ) {

$footerlinks['contact'] = Html::rawelement( 'a', [

'href' => Title::newFromText(

$skin->msg( 'contactpage-msgkey' )->inContentLanguage()->text()                               

),

],

$skin->msg( 'contactpage-label' )

);

};

};


But generated page URL is example.org/index.php/Special:Contact (without CGI support)

Expected URl is example.org/index.php?title=Special:Contact (with CGI support)


Can help me?

Thanks a lot.

Reply to "Server support CGI, but custom added page using Title::newFromText page addresses is not CGI style"

Setting short URLs breaks CSS, causes most links to 404

3
129.19.129.22 (talkcontribs)

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?

129.19.129.22 (talkcontribs)

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 set AllowOverride 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.
Dylan Banta (talkcontribs)

I'm having this same issue but I'm using Nginx, does anyone know what kind of changes I need to make for Short URLs with nginx?


Edit: Resolved


server {

   # your existing server configuration

   # ...

   # Short URLs for MediaWiki

   location /wiki {

       try_files $uri $uri/ @mediawiki;

   }

   location @mediawiki {

       rewrite ^/wiki(/.*)?$ /index.php?$1 last;

   }

   location ~ \.php$ {

       # your existing PHP configuration

       # ...

       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

       include fastcgi_params;

   }

   # ...

}

Reply to "Setting short URLs breaks CSS, causes most links to 404"

is this on the roadmap

2
Mapmaker345 (talkcontribs)

this is clunky as hell. is short URLs by default on the roadmap?

FeralOink (talkcontribs)

It would be much appreciated to have a not clunky short URL.

Reply to "is this on the roadmap"
80.255.7.101 (talkcontribs)

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 ;)

85.106.107.70 (talkcontribs)

did you able to solve that? I have the same problem either

85.106.107.70 (talkcontribs)
80.62.119.211 (talkcontribs)

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.

Vivaporius (talkcontribs)

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.

Dantman (talkcontribs)

$wgArticlePath = "/wiki/$1";

Vivaporius (talkcontribs)
Vivaporius (talkcontribs)

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?

Reply to "How to change my URL"

Visual Editor seems to defeat attempts at short URLs

2
Tiffany352 (talkcontribs)

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.

Kghbln (talkcontribs)

I reported a similar issue as task T270376 I am pretty sure that you are currently out of luck.

Reply to "Visual Editor seems to defeat attempts at short URLs"

Continue to utilize links at old short url

1
Vapblack (talkcontribs)

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?

Reply to "Continue to utilize links at old short url"
Rehman (talkcontribs)

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!

Þjarkur (talkcontribs)

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 = "/";

Rehman (talkcontribs)

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...

Rehman (talkcontribs)

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")?

Bawolff (talkcontribs)

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

Rehman (talkcontribs)

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.

Bawolff (talkcontribs)

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/

Rehman (talkcontribs)

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?

Ciencia Al Poder (talkcontribs)

Looking at your configuration

Your Script path is /w, but it should be /

Everything else seems correct

Rehman (talkcontribs)

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.

Bawolff (talkcontribs)

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";
Rehman (talkcontribs)

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.

Reply to "Seems to be buggy"

Short URL for non-latin wikis

2
Alexey Skripnik (talkcontribs)
Þjarkur (talkcontribs)

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.

Reply to "Short URL for non-latin wikis"