Page MenuHomePhabricator

Rewrite rules not functioning...
Closed, InvalidPublic

Description

Author: ipaqchoice

Description:
I tried them all, but they don't seem to be working... The rewrite_rules page and
discussion don't seem to have updated info for version 1.4...

If *anyone* has version 1.4 running could you please post what you have in
your .htaccess and your localsettings.php to make the rewrite work? Basically i setup
wiki.mydomain.com to point to mydomain.com/wiki.... What i would like is for the
whole thing to be wiki.mydomain.com/article_name

If you have something similar please post it...

Thanks a bunch


Version: 1.4.x
Severity: enhancement
OS: Windows XP
Platform: PC
URL: http://meta.wikimedia.org/wiki/Rewrite_rules

Details

Reference
bz1562
TitleReferenceAuthorSource BranchDest Branch
Pin essential conda-analytics packagesrepos/data-engineering/conda-analytics!43stevemunenepin_essential_conda_analytics_packagesmain
Draft: Pin essential conda-analytics packagesrepos/data-engineering/conda-analytics!42stevemunenepin_essential_conda_analytics_packagesmain
Update function-schemata sub-module to HEAD (bd1742b)repos/abstract-wiki/wikifunctions/wikilambda-cli!28jforrestersync-function-schematamain
Update function-schemata sub-module to HEAD (bd1742b)repos/abstract-wiki/wikifunctions/function-evaluator!146jforrestersync-function-schematamain
Update function-schemata sub-module to HEAD (bd1742b)repos/abstract-wiki/wikifunctions/function-orchestrator!125jforrestersync-function-schematamain
definitions: Add Z1921/pey ZNaturalLanguagerepos/abstract-wiki/wikifunctions/function-schemata!81jforresterlanguage-peymain
add checkout customization for MediaWiki chartrepos/qte/catalyst/ci-charts!5jnucheT356264main
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:16 PM
bzimport set Reference to bz1562.
bzimport added a subscriber: Unknown Object (MLST).

jeluf wrote:

Please be more specific than "does not work".

ipaqchoice wrote:

(In reply to comment #1)

Please be more specific than "does not work".

Thanks for replying...

getting "500 internal server error"...

perhaps you can tell me what you have in your files so i can try setting it up the same way?

(In reply to comment #0)

I tried them all, but they don't seem to be working... The rewrite_rules page and
discussion don't seem to have updated info for version 1.4...

I support you. Installing a mediawiki can take less than 2 minutes, but trying
rewriting can be a horror story.

Perhaps, please, can someone of the developers check and update the info on
http://meta.wikimedia.org/wiki/Rewrite_rules ?

URL rewriting is external to MediaWiki and there should be no difference at
all between 1.3 and 1.4 in this regard.

If you're getting 500 Internal Server Error problems, a common problem is
using an .htaccess file with directives that your Apache configuration does
not allow you to override in an .htaccess file. If you're running your own
server, check the settings in the global configuration; if you're on a shared
host ask your system administrator. Show them the .htaccess file you're
trying to use, ask if that's allowed and if there's a change either you or they
can make to get it working.

ipaqchoice wrote:

(In reply to comment #4)

URL rewriting is external to MediaWiki and there should be no difference at
all between 1.3 and 1.4 in this regard.
If you're getting 500 Internal Server Error problems, a common problem is
using an .htaccess file with directives that your Apache configuration does
not allow you to override in an .htaccess file. If you're running your own
server, check the settings in the global configuration; if you're on a shared
host ask your system administrator. Show them the .htaccess file you're
trying to use, ask if that's allowed and if there's a change either you or they
can make to get it working.

I have other scripts on the site (serendipity blog) that has an option in the web interface to use rewriting (i checked the htaccess file it
produced and it's like this:

BEGIN s9y

ErrorDocument 404 /serendipity/index.php
DirectoryIndex /serendipity/index.php

RewriteEngine On
RewriteBase /serendipity/
RewriteRule ^archives/(\d+)\.html index.php?url=/archives/$1.html [L,QSA]
RewriteRule ^archives/(\d+)[_\-]short\.html index.php?url=/archives/$1-short.html [L,NC,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^admin$ serendipity_admin.php [L,QSA]
RewriteRule ^entries$ serendipity_entries.php [L,QSA]
RewriteRule ^archive$ index.php?url=/archive [L,QSA]
RewriteRule ^categories/(\d+)[_\-].* index.php?url=archive/$1 [L,QSA]
RewriteRule ^(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$ rss.php?file=$1&ext=$2
RewriteRule ^plugin/(.*) index.php?url=plugin/$1 [L,QSA]
RewriteRule ^index\.(html?|php.?) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]

<Files *.tpl>

deny from all

</Files>

<Files *.sql>

deny from all

</Files>

<Files *.inc.php>

deny from all

</Files>

<Files *.db>

deny from all

</Files>

END s9y

It works perfectly ok. Looks like this now http://www.mydomain.com/serendipity/archives/1-article.html.

I tried several of the uggestions from the rewrite_rules page and the talk:rewrite_rules, but this is what happened:

First tried modifying htaccess (+ added |skins to rewrite rules as per instructions) without touching localsettings.php... mydomain.com/wiki
automatically redirected to mydomain.com/wiki/index.php?title=Main_page ... then modified localsettings.php as per suggestions... same
thing. Tried other users' implementations... same thing or didn't work. Then removed htaccess and reverted localsettings.php back, then the
main page appears without any skin. I don't know what i did to revert it back to normal again. So then i stopped trying.

If you know what should be included in the htaccess and localsettings for 1.4beta6 to work Brion, please tell. I would appreciate it a lot,
as i'm sure others will too...

Thanks.

wegge wrote:

(In reply to comment #0)

I tried them all, but they don't seem to be working... The rewrite_rules page and
discussion don't seem to have updated info for version 1.4...

If *anyone* has version 1.4 running could you please post what you have in
your .htaccess and your localsettings.php to make the rewrite work? Basically

i setup

wiki.mydomain.com to point to mydomain.com/wiki.... What i would like is for the
whole thing to be wiki.mydomain.com/article_name

If you have something similar please post it...

The URL rewrites described on http://wiki.wegge.dk/MediaWiki_customizations
works for me. Are you absolutely sure that you remebered the RewriteEngine on
directive?

ipaqchoice wrote:

(In reply to comment #6)

(In reply to comment #0)

I tried them all, but they don't seem to be working... The rewrite_rules page and
discussion don't seem to have updated info for version 1.4...

If *anyone* has version 1.4 running could you please post what you have in
your .htaccess and your localsettings.php to make the rewrite work? Basically

i setup

wiki.mydomain.com to point to mydomain.com/wiki.... What i would like is for the
whole thing to be wiki.mydomain.com/article_name

If you have something similar please post it...

The URL rewrites described on http://wiki.wegge.dk/MediaWiki_customizations
works for me. Are you absolutely sure that you remebered the RewriteEngine on
directive?

I followed the instructions on the site you listed to the letter, and basically this is what happens: http://mydomain.com/wiki and
http://mydomain.com/wiki/index.php return a 404 not found error, http://mydomain.com/wiki/index.php?title=Main_page returns the normal main
page, but then clicking a link from there returns a non-skinned page. The rewrites don't seem to work as it still shows up as index.php?
title= ...

This is what i put in the .htaccess: (notice i changed /w/ to /wiki/)

  1. Rewrite rules for a MW installation with normal article view
  2. without index.php and /w/ in front of all other links.

RewriteEngine on

  1. Don't rewrite requests for files in MediaWiki subdirectories,
  2. MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt

RewriteCond %{REQUEST_URI} !^/(stylesheets|images|skins)/
RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php
RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_URI} !^/robots.txt
RewriteCond %{REQUEST_URI} !^/wiki/

Rewrite anything not matched by the rules above.

RewriteRule ^/(.*)$ /index.php/$1 [L,QSA]

Remove the /w/ from the edit links

RewriteRule ^/wiki/(.*)$ /$1 [L,QSA]

Here is my LocalSettings.php:

<?php

  1. This file was automatically generated by the MediaWiki installer.
  2. If you make manual changes, please keep track in case you need to
  3. recreate them later.

$IP = "/home/content/m/i/b/mibolox/html/wiki";
ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages" );
require_once( "includes/DefaultSettings.php" );

  1. If PHP's memory limit is very low, some operations may fail.
  2. ini_set( 'memory_limit', '20M' );

if ( $wgCommandLineMode ) {
if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {

		die( "This script must be run from the command line\n" );

}
} elseif ( empty( $wgConfiguring ) ) {

  1. Compress output if the browser supports it

if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
}

$wgSitename = "MyDomain";

$wgScriptPath = "";
$wgScript = "$wgScriptPath/wiki/index.php";
$wgRedirectScript = "$wgScriptPath/redirect.php";

    1. If using PHP as a CGI module, use the ugly URLs
  1. $wgArticlePath = "$wgScriptPath/$1";

$wgArticlePath = "$wgScriptPath/$1";

$wgStylePath = "$wgScriptPath/skins";
$wgStyleDirectory = "$IP/skins";
$wgLogo = "$wgStylePath/common/images/wiki.png";

$wgUploadPath = "$wgScriptPath/images";
$wgUploadDirectory = "$IP/images";

$wgEmergencyContact = "support@mydomain.com";
$wgPasswordSender = "support@mydomain.com";

$wgDBserver = "mysql12.secureserver.net";
$wgDBname = "mywiki";
$wgDBuser = "mywiki";
$wgDBpassword = "wiki1111";
$wgDBprefix = "";

    1. To allow SQL queries through the wiki's Special:Askaql page,
    2. uncomment the next lines. THIS IS VERY INSECURE. If you want
    3. to allow semipublic read-only SQL access for your sysops,
    4. you should define a MySQL user with limited privileges.
    5. See MySQL docs: http://www.mysql.com/doc/en/GRANT.html #
  1. $wgAllowSysopQueries = true;
  2. $wgDBsqluser = "sqluser";
  3. $wgDBsqlpassword = "sqlpass";

If you're on MySQL 3.x, this next line must be FALSE:

$wgDBmysql4 = $wgEnablePersistentLC = true;

Shared memory settings

$wgUseMemCached = false;
$wgMemCachedServers = array();
#$wgUseTurckShm = function_exists( 'mmcache_get' ) && php_sapi_name() == 'apache';

  1. To enable image uploads, make sure the 'images' directory
  2. is writable, then uncomment this:

$wgDisableUploads = false;
$wgUseImageResize = true;

  1. $wgUseImageMagick = true;
  2. $wgImageMagickConvertCommand = "/usr/bin/convert";
    1. If you have the appropriate support software installed
    2. you can enable inline LaTeX equations:
  1. $wgUseTeX = true;

$wgMathPath = "{$wgUploadPath}/math";
$wgMathDirectory = "{$wgUploadDirectory}/math";
$wgTmpDirectory = "{$wgUploadDirectory}/tmp";

$wgLocalInterwiki = $wgSitename;

Specify who can edit: true means only logged in users may edit pages

$wgWhitelistEdit = true;

#$wgGoToEdit = true;

$wgLanguageCode = "en";
$wgUseLatin1 = false;

Specify if Users can use mystyle.css in their User:Name/mystyle.css page

#$wgAllowUserCss = true;

#The wiki cache does not automatically have articles purged that reference a
#newly created or deleted category, perhaps for performance reasons.
#A better work-around is to use the action=purge option to flush the wiki cache,
#e.g. .../index.php?title=The_article&action=purge
#Caching at the wiki can be disabled by adding the following line to LocalSettings.php
#$wgEnableParserCache = false;

$wgProxyKey = "424a4be25072385e2589ff7e573b1567787b084174f02325387c1ed24227a353";

    1. Default skin: you can change the default skin. Use the internal symbolic
    2. names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
  1. $wgDefaultSkin = 'monobook';
    1. For attaching licensing metadata to pages, and displaying an
    2. appropriate copyright notice / icon. GNU Free Documentation
    3. License and Creative Commons licenses are supported so far.
  1. $wgEnableCreativeCommonsRdf = true;

$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";

$wgRightsCode = ""; # Not yet used

?>

If the code looks ok to you then i'll just give up... i don't think it's a server problem as rewrite works with another script i have
(serendipity)...

Just a quick question though... i put the .htaccess in the /wiki directory where the wiki is... did you put it in the root folder? If not,
do you have anything special in the htaccess of the root folder? Maybe it didn't work for me because you set your script to remove ethe /w/
part for you... but i need to keep the /wiki/ part of the URL... do you know how to modify the htaccess and the LocalSettings.php in that
case?

Thanks