Topic on Extension talk:VisualEditor

Error contacting the Parsoid/RESTBase server (HTTP 404) when using short links.

10
Orribu (talkcontribs)
Product Version
MediaWiki 1.35.1
PHP 7.3.25 (cgi-fcgi)
MySQL 5.7.26-29-log
ICU 63.2

Shared hosting, Siteground

Apache/Nginx Compatible Server

.htaccess file has been created to assist in link shortening.


I'm having some trouble getting VisualEditor (herein referred to as VE) to work. It worked perfectly out the box when I installed MediaWiki and activated it, but the second I tried to shorten links (hide the index.php?title=main_page), it broke. Here are the steps I took:

  1. Installed MediaWiki 1.35.1.
  2. Created .htaccess file to activate rewrite capabilities. (VE worked at this point)
  3. Added " $wgScriptExtension = ".php"; $wgArticlePath = "/$1"; "


When I added that code to shorten the link from "https://example.net/index.php?title=Main_Page" to "https://example.net/Main_Page", I suddenly got the 404 error. Removing those lines of code results in the extension working as expected.

I've added my two cents to this bug report, as it's pretty close to if not exactly the issue I'm going for. Only difference is my .htaccess file doesn't harm the functionality of VE. There are many bug reports on phabricator with the same issues. I've tried the steps outlined in VE's troubleshooting section on the extension page for 404 errors, but nothing seems to work. I don't think I have root access. Any ideas what's going on?

Orribu (talkcontribs)

As an update, I can't create new pages using VE either; I get the same error when I go to save changes.

TiltedCerebellum (talkcontribs)

Looks like currently VE won't work with Short URL per T270376, and it won't work on subpages if users don't have access to apache config files to do the VE doc recommended AllowEncodedSlashes NoDecode (which can't be done in .htaccess). The closest I could get to a shorter URL config was the default /wiki/ setup.

What worked in my case was to ensure the site was on https, then to have in LocalSettings.php:

$wgScriptPath = "/w"; # Folder MW is installed in on server
$wgArticlePath = "/wiki/$1"; # Short URL path shown in browser

Also ensure this line had https:

$wgServer = "https://www.sitename.com";


And in .htaccess (apache non-root config file, at root web level, not in the w folder):

RewriteEngine on
RewriteBase /

# Rewrites all URLS without blog in them
RewriteCond %{REQUEST_URI} !^/w/

# Rewrites all URLS [Replace "example-sitename" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example-sitename\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /w/$1 [L]
Orribu (talkcontribs)

Hey @TiltedCerebellum, thanks for the input! I've reconfigured the wiki to point to /wiki/$1! Unfortunately, I've run into another snag. It's giving me a 500 error this time:


Error contacting the Parsoid/RESTBase server (HTTP 500)


I tried doing the .htaccess in both the root and mediawiki folders and got a 404. I moved the .htaccess to the root instead of the mediawiki folder and got the same issue. Am I doing something wrong?

TiltedCerebellum (talkcontribs)

Are you wikis physical files nested in a /w/ folder in its web directory? Basically I had to use the recommended default MediaWiki setup that Wikipedia uses. My files were not nested in a /w/ folder in the web directory... I had to move it there and figure out the recommended URL rewrites from my host to cause it to redirect the domain to see the files in a subdirectory rather than web root. From your prior settings it looks like you have your MediaWiki files in web root instead of nested in a /w/ folder?

That told the browser that my site files physically lives in site.com/w/ (a subdirectory /w/ in my web directory), but the URL was rewritten to look like it is living in site.com/wiki/ . That was the only setup under which I was currently able to get VE working as intended. Though it still doesn't work on subpages, I see multiple bug reports regarding that--a problem with VE itself. No idea if that helps (I'm just a user of MW like you, and this was just the only config that worked for me on my host). You might need assistance from VE extension developer/user or a MediaWiki Support Desk member.

Orribu (talkcontribs)

Hey there, thanks for getting back to me! I really appreciate your help and patience with this matter.

I've done as you instructed and nested my installation in a "w" folder, so now the site physically lives in wiki.twistedfates.net/w/.

That url works, but the second I edit LocalSettings.php and add the $wgArticlePath = "/wiki/$1"; I get a 404 error. Commenting the ArticlePath line out allows wiki.twistedfates.net/w/ to work again.


So just to recap to make sure I've understood you correctly, I have the following code in /.htaccess:

RewriteEngine on

RewriteBase /

# Rewrites all URLS without blog in them

RewriteCond %{REQUEST_URI} !^/w/

# Rewrites all URLS [Replace "example-sitename" with the actual domain, without the TLD (.com, .net, .biz, etc)]

RewriteCond %{HTTP_HOST} ^(www\.)?example-sitename\.

# Rewrite all those to insert /folder

RewriteRule ^(.*)$ /w/$1 [L]

(I replaced "example-sitename" with "wiki.twistedfates" but I could be misunderstanding something!)


Then, I added the following lines in /w/LocalSettings.php:

$wgScriptPath = "/w"; # Folder MW is installed in on server

$wgArticlePath = "/wiki/$1"; # Short URL path shown in browser


Just to triple-check, I have ensured that wgServer contains https:// instead of http://.

I just can't seem to get the shortened URL to work...

TiltedCerebellum (talkcontribs)

You're probably better off following the MW Short URL/Apache simple manual example than my example for the URL rewrites, or seeing if someone from the help desk can provide a solid answer, I'm not good at this part myself frankly. I wasn't able to get their example working properly because I simply don't know enough about this, so not a good person to ask for this, sorry.

If mine did work (and isn't incorrect--not sure it's the right way to do it AT ALL), I'd think you'd end up with something like:

RewriteCond %{HTTP_HOST} ^(wiki\.)?twistedfates\.


Then I'd try accessing pages for viewing-specifically at: https://wiki.twistedfates.net/wiki/?

Orribu (talkcontribs)

Aw no worries! Thank you so much for helping out. We'll figure this shortURL business out and hopefully VE will be compatible with /$1 in the future!

TiltedCerebellum (talkcontribs)

Yw. I hope so too, we prefer it with that config also... many of our uses are used to typing certain things direct in the URL so having the added /wiki/ threw everyone off. Having the edit page URL be /w/ and the view page url being /wiki/ also threw them off. :|

176.232.58.40 (talkcontribs)

i am done with this nonsense i will use classic editor now....

why release with software if it has this issues at first plase for god sake !

Reply to "Error contacting the Parsoid/RESTBase server (HTTP 404) when using short links."