Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Removing index.php?p=/ from URL while using IIS6

Hi there,

I've installed Vanillaforums on my Windows 2003 box running IIS 6. So good so far but I'm not happy with the URL shown in the browser. I'd like to get rid of the index.php?p=/ string. I've already searched in the community for a solution and found this: http://vanillaforums.org/discussion/15322/how-to-remove-index.phpp-from-all-urls/p1.

It sounds good but it seems to not work on an IIS. When I try to change the conf file, the startpage comes up but as soon as I navigate to discussions or whatever, it rans into a 404.

I know the issue because I had that before with Wordpress as well. For WP there is an option where you can use a custom 404 file. I can't remember where I got it from but it looks like this:

<?php
// This is the default file for the site. Usually index.php
$default = 'index.php';

// The name of this file.
// Set this value for the URL in Custom Error Properties of your website in IIS.
// Goto: IIS Manager > Websites > [Site Name] > Properties > Custom Errors >
// 404 & 404;2 & 404;3 > URL (Requires a '/' prefix in IIS).
$thisfile = '404-handler.php';

$_SERVER['ORIG_PATH_TRANSLATED'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_TRANSLATED']);
$_SERVER['SCRIPT_FILENAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_FILENAME']);
$_SERVER['ORIG_PATH_INFO'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_INFO']);
$_SERVER['SCRIPT_NAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_NAME']);
$_SERVER['PHP_SELF'] = str_replace($thisfile, $default, $_SERVER['PHP_SELF']);
$_SERVER['PATH_INFO'] = false;

$qs =& $_SERVER['QUERY_STRING'];
$ru =& $_SERVER['REQUEST_URI'];
$pos = strrpos($qs, '://');
$pos = strpos($qs, '/', $pos + 4);
$_SERVER['URL'] = $ru = substr($qs, $pos);
$qs = trim(stristr($ru, '?'), '?');

// Required for Wordpress 2.8+
$_SERVER['HTTP_X_ORIGINAL_URL'] = $ru;

// Fix GET vars
foreach ( $_GET as $var => $val ) {
if ( substr($var, 0, 3) == '404') {
if ( strstr($var, '?') ) {
$newvar = substr($var, strpos($var, '?') + 1);
$_GET[$newvar] = $val;
}
unset($_GET[$var]);
}
break;
}
include($default);
?>


When using this file as a custom error file for 404 I'm always getting redirected to the index.php when navigating to discussions and the other options.

Unfortunately I'm not a developer and I really don't know what to change in the code.

Did anyone come around with this problem too?

Help really appreciated.

Thanks,

Christoph

Comments

  • I got it working now. The way described in the post mentioned above is the right one. I'm using Helicon ISAPI Rewrite as a mod_rewrite component. This ISAPI module needs some more permissions on the web folder. The Usergroup IIS_WPG needs read, write and list content rights.
Sign In or Register to comment.