Topic on Project:Support desk

ERR_TOO_MANY_REDIRECTS on a new wiki with rewrite

11
Summary by Ciencia Al Poder
Fireflyt (talkcontribs)

Hi all,

I have started setting up a new wiki as part of our upgrade testing to a newer version of the wiki. We have a development server I use to test any new version before we upgrade.

Our current setup is Server 2008 R2 with IIS7.5, PHP 5.6.

After setting up Mediawiki 1.26.0 and adding the rewite setup, I am getting a ERR_TOO_MANY_REDIRECTS error whenever I try to browse to non main namespace areas, i.e. Special pages. This has always worked fine on our production environment which uses Mediawiki 1.25wmf24 (we are testing Visual Editor). The URL goes to "http://developmentwiki1.spirehealthcare.net/wiki/Special%3ASpecialPages" for special pages. This again works fine in production.

Any help would be greatly appreciated as I have compared the setup on both the production and development wiki's with no success. I have even tried setting up 1.26.0 from scratch. I have tried a number of suggested fixes I have seen, but have also not worked.

Our localsettings.php section for this is:

$wgSitename = "Development1wiki";

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

$wgArticlePath = '/wiki/$1'; # Virtual path. This directory MUST be different from the one used in $wgScriptPath

## The protocol and server name to use in fully-qualified URLs

$wgServer = "http://developmentwiki1.spirehealthcare.net";

## The URL path to static resources (images, scripts, etc.)

$wgResourceBasePath = $wgScriptPath;

The IIS rewrite rule is:

Pattern: ^wiki/(.*)$

Rewrite URL: /index.php?title={R:1}

I really appreciate any help in advance.

128.71.41.220 (talkcontribs)
Fireflyt (talkcontribs)

Nice, this fixes the issue!!

Poisonnuke (talkcontribs)

Same issue on Ubuntu 16.04 with Apache 2.4

clean installation, NO mod_rewrite

this fix should be made permanent without checking for IIS, because it is not failure of IIS but of mediawiki.

M.lazzarotto (talkcontribs)

Hi, I have the same issue on Ubuntu 14.04, Apache 2.4.7 and PHP 5.5.9.

A couple of days ago I upgraded MediaWiki from 1.25.2 to 1.27.1.

We have an Apache server that runs as a reverse proxy and redirects the connections to this server.

When I upgraded I was having Too many redirects error, so I rolled back the changes.

Perhaps should I to set the $wgHTTPProxy variable?

Fireflyt (talkcontribs)
M.lazzarotto (talkcontribs)

Thank you.

I'm not a developer, I am just a sysadmin and I don't know how to code.

What should I change from the code in the blog?

If I understand, I should just keep from the 4th to the 8th lines, and replace the original code with this

if ( urldecode($targetUrl) != urldecode($request->getFullRequestURL()) )  {

    

$output->setCdnMaxage( 1200 );

    

$output->redirect( $targetUrl, '301' );

    

return true;

  

}

Fireflyt (talkcontribs)

You just open the file /includes/MediaWiki.php in an file editor -

and change that bit of code with what is in the bottom section of the solution. The one you have there is what it is at the moment.

M.lazzarotto (talkcontribs)

The replacement of the code didnt' worked for me.

I had to change the line 344 from

if ( $targetUrl != $request->getFullRequestURL() ) {

to

if ( $targetUrl == $request->getFullRequestURL() ) {

Iistman (talkcontribs)

I moved a wiki from older Mediawiki version to 1.27.1 and got this redirecting problem when I was editing with the new wiki. At some point I got more informative error from the server and put $wgUsePathInfo = false; to my LocalSettings.php. Then I did maintenance/rebuildall.php. After a little testing I couldn't get the error to pop up anymore.

Internal Server Error

Redirect loop detected!

This means the wiki got confused about what page was requested; this sometimes happens when moving a wiki to a new server or changing the server configuration.

The wiki is trying to interpret the page title from the URL path portion (PATH_INFO), which sometimes fails depending on the web server. Try setting "$wgUsePathInfo = false;" in your LocalSettings.php, or check that $wgArticlePath is correct.
50.37.25.241 (talkcontribs)

Changing the line to:

if ( urldecode($targetUrl) != $request->getFullRequestURL() ) {

Fixes the problem in IIS8 for me. You do not need to urldecode the full url as it is not encoded.

Reply to "ERR_TOO_MANY_REDIRECTS on a new wiki with rewrite"