Topic on Project:Support desk

Short URL Redirects to index.php

16
136.158.7.154 (talkcontribs)

Hi.

I am currently implementing the short url into my wiki. It works, however it does not redirect to the wiki url but the index.php file.

Everything is copied from the short url configs.

Thanks in advance.

Ciencia Al Poder (talkcontribs)
136.158.7.154 (talkcontribs)

I did copy everything.

Ciencia Al Poder (talkcontribs)
136.158.7.154 (talkcontribs)

It’s not really helping since I already told you that I copied everything.

Ciencia Al Poder (talkcontribs)

The information you provide is not helpful either to figure out what's wrong.

You can start by sharing your configuration, link to your site, etc

2404:3C00:255D:3100:0:0:0:2 (talkcontribs)

Hi,

Same user as before. Coping it led to a 404 error.

2404:3C00:255D:3100:0:0:0:2 (talkcontribs)

Here is the code:

# Enable the rewrite engine
RewriteEngine On

# Short URL for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

LocalSettings.php:

$wgScriptPath = "/w";     
$wgArticlePath = "/wiki/$1";
Ciencia Al Poder (talkcontribs)

If you manually type an index.php URL, it won't redirect to a /wiki/ URL.

The configuration purpose is:

  • The wiki will generate /wiki/ URLs on normal view links (not edit, diff, history links). This is the LocalSettings.php configuration.
  • Your webserver will recognize /wiki/ URLs and translate them into /w/index.php URLs (without a redirect, browser will stay at /wiki/). This is what the apache configuration does.

Does it work for you as I explained?

136.158.7.154 (talkcontribs)

I have done it to an article link, it still leads to a 404 error.

Ciencia Al Poder (talkcontribs)

Basically, it looks like your rewrite rules are not applied, or %{DOCUMENT_ROOT} points to the wrong location.

Try changing %{DOCUMENT_ROOT}/w/index.php to the full path of index.php (in the filesystem).ç

Also, set up some debugging to see how the rewrite is being done (or if it's being applied at all): https://stackoverflow.com/a/9632952/7268905

136.158.7.154 (talkcontribs)

It’s still the same, even with the webroot in.

Ciencia Al Poder (talkcontribs)

Debugging is your only option. Or your server is pretty broken

136.158.7.154 (talkcontribs)

How do I see the debug output?

Ciencia Al Poder (talkcontribs)

See the stackoverflow link I posted before

136.158.7.154 (talkcontribs)

There is a error log, which says $wgPasswordSender and $wgEnableEmail are undefined and unexpected in that order.

For the first one $wgResourceBasePathki is undefined. I cant find any reference to it in MediaWiki.

The second one says that the variable is unexpected.

There is a third one where the string “apache” is unexpected, and it expected a closing [.

All lines go to the variables, $wgPasswordSender to itself, $wgEnableEmail to $wgEmailAuthentication, and the Apache to $wgDBserver

Reply to "Short URL Redirects to index.php"