Mailing List Archive

Rewrite rules and .htaccess
Perhaps this isn't the place to ask this, but....

I'm having trouble getting the rewrite rules to work properly. I can access
my site with:

http://my.url.here/index.php/Article_name

Everything works fine with the URL like this, but I want to eliminate the
"index.php" part of the URL.

When I change my LocalSettings.php and .htaccess (following the user guide's
directions on rewrite rules) the URL rewrite happens. In other words, my
browser tries to get "http://my.url.here/Main_page".

BUT, this results in a "Not found" error (404).


Here's my .htaccess file:
-----------------------------------------------------
# Allow wiki articles to start with a period
<Files .*>
Order Deny,Allow
Allow From All
</Files>

# Allow rewriting URLs
RewriteEngine on

# Don't rewrite requests for files in MediaWiki subdirectories,
# MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt
RewriteCond %{REQUEST_URI} !^/(stylesheets|images)/
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

# Rewrite http://wiki.domain.tld/article properly, this is the main rule
RewriteRule ^/(.*) /index.php/$1 [L]

-----------------------------------------------------

And here's my LocalSettings.php file:

<?php

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

$IP = "/home/my_name/public_html/wikisite";
ini_set( "include_path", "$IP/includes:$IP/languages:" .
ini_get("include_path") );
include_once( "DefaultSettings.php" );

if( $wgCommandLineMode ) {
die( "Can't use command-line utils with in-place install yet, sorry." );
} else {
## Compress output if the browser supports it
if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
}

$wgSitename = "wikisite";

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

## If using PHP as a CGI module, use the ugly URLs
$wgArticlePath = "/$1";
# $wgArticlePath = "$wgScript?title=$1";

$wgStyleSheetPath = "/stylesheets";
$wgStyleSheetDirectory = "$IP/stylesheets";

$wgUploadPath = "/images";
$wgUploadDirectory = "$IP/images";
$wgLogo = "$wgUploadPath/wiki.png";
$wgStockPath = $wgUploadPath;

$wgEmergencyContact = "wwwadmin@wikisite.tld";
$wgPasswordSender = "wwwadmin@wikisite.tld";

$wgDBserver = "localhost";
$wgDBname = "database";
$wgDBuser = "user";
$wgDBpassword = "password";

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

$wgDBmysql4 = $wgEnablePersistentLC = true;

## To enable image uploads, make sure the 'images' directory
## is writable, then uncomment this:
# $wgDisableUploads = false;
$wgUseImageResize = true;
# $wgUseImageMagick = true;
# $wgImageMagickConvertCommand = "/usr/bin/convert";

## If you have the appropriate support software installed
## you can enable inline LaTeX equations:
# $wgUseTeX = true;
$wgMathPath = "{$wgUploadPath}/math";
$wgMathDirectory = "{$wgUploadDirectory}/math";
$wgTmpDirectory = "{$wgUploadDirectory}/tmp";

$wgLocalInterwiki = $wgSitename;

$wgLanguageCode = "en";
$wgInputEncoding = $wgOutputEncoding = "UTF-8";


?>
-------------------------------------------------------------------

Any ideas?

Bruce
Re: Rewrite rules and .htaccess [ In reply to ]
Bruce Bertrand wrote:
> When I change my LocalSettings.php and .htaccess (following the user guide's
> directions on rewrite rules) the URL rewrite happens. In other words, my
> browser tries to get "http://my.url.here/Main_page".
>
> BUT, this results in a "Not found" error (404).

Can you confirm that you can use rewrite rules in an .htaccess on your
setup? Try something very simple like:

RewriteEngine on
RewriteRule ^/fake.html /real.html

-- brion vibber (brion @ pobox.com)
Re: Rewrite rules and .htaccess [ In reply to ]
On Saturday 29 May 2004 02:41 am, Brion Vibber wrote:
> Bruce Bertrand wrote:
> > When I change my LocalSettings.php and .htaccess (following the user
> > guide's directions on rewrite rules) the URL rewrite happens. In other
> > words, my browser tries to get "http://my.url.here/Main_page".
> >
> > BUT, this results in a "Not found" error (404).
>
> Can you confirm that you can use rewrite rules in an .htaccess on your
> setup? Try something very simple like:
>
> RewriteEngine on
> RewriteRule ^/fake.html /real.html
>
> -- brion vibber (brion @ pobox.com)

Nope! The above entries for .htaccess do nothing.
Do you know of any other way to do this (if it's possible)?
This is odd though, as rewrite used to work for this server. They just moved
to a new datacenter this past weekend, but the config files shouldn't have
been changed.

How can I see the apache configuration? (the actual config files aren't
readable by my account. it's a shared host)

Bruce