This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: rewrite being weird
Author
Message |
madninjaskillz
Newbie


Joined: 26 June 2010
Posts: 5
Posted: 26 June 2010 at 11:33am

just installed wordpress3 and purchased a server license for ape to
compliment it.

Having loads of issues with the htacess file.

Code:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\d+)/[^/]+/?$ /index.php?p=$1 [NC,L]


works for posts, but only posts.

Code:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


works for nothing (it returns to the homepage)

if i use a permalink that includes index.php (the default ones) i just get a
white screen.

Any help would be amazing.
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 26 June 2010 at 2:34pm

Hello,
Please use the following code:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


And you should add the following at the top of the index.php:
Code:
if (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}


__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
madninjaskillz
Newbie


Joined: 26 June 2010
Posts: 5
Posted: 26 June 2010 at 3:47pm

still no joy :(

keeps redirecting to home page :(

EDIT:

just added an echo to print out the server variables, and http_x_rewrite_url
isnt ever set.

Edited by madninjaskillz - 26 June 2010 at 3:49pm
Back to Top
 
madninjaskillz
Newbie


Joined: 26 June 2010
Posts: 5
Posted: 26 June 2010 at 4:45pm

Code:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /index.php?uri=$1 [L]


and in the php

Code:

if (isset($_GET["uri"])){
$_SERVER['REQUEST_URI']=$_GET["uri"];
}


this works. a little annoyed that its broken enough that ive resorted to
tricks i could have acheived with a custom 404 page. It doesnt entirely
work (buddy press stuff is screwed) but its the closest ive had yet.
Back to Top
 
madninjaskillz
Newbie


Joined: 26 June 2010
Posts: 5
Posted: 27 June 2010 at 4:19am

404.php:

Code:

<?php

$pth=str_replace("404;http://<PUT YOUR SITE URL HERE OR USE SERVER
VAR>:80","",
$_SERVER['QUERY_STRING']);
// 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.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, '?'), '?');
$ru=$pth;
// Required for Wordpress 2.8+
$_SERVER['HTTP_X_ORIGINAL_URL'] = $ru;
$_SERVER['REQUEST_URI']=$ru;
$_SERVER['HTTP_X_REWRITE_URL']=$ru;
$_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);
?>


APE no longer required, works more reliably too. APE's handling of rewrite
rules seems a little hit and miss.

Edited by madninjaskillz - 27 June 2010 at 4:21am
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 27 June 2010 at 5:06am

Hello,
You may try the following solution:
Code:
SetEnvIf %{REQUEST_URI} (.*) HTTP_X_REWRITE_URL=$1

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]


And this must be at the top of the index.php:
Code:
if (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}


I understand that you have found different solution, but Helicon Ape isn’t just the mod_rewrite. There is a bunch of another useful features. Please check out our article on how to tweak WordPress with Helicon Ape:
http://helicontech.blogspot.com/search/label/Wordpress

Thank you.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
madninjaskillz
Newbie


Joined: 26 June 2010
Posts: 5
Posted: 27 June 2010 at 5:26am

Vyacheslav,

Thanks very much for your support. the 404 solution is not my favourite
thing in the world, and id much rather get APE to work.

ive noticed one worrying thing. if you remove APE from a site, then re-
enable it, the wildcard matching that it does for iis 6 adds the .net 1.1
version of isapi_net, not the 2.x version recommended in the iis6 guide.

when it does this, EVERY page is a 404.

ive now implimented your code (with a slash before index.php in bottom
line since permalinks mean its not in the root dir so is required)

http://beta.ezmuze.co.uk/

as you can probably see, no joy :(

EDIT:

if (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
echo "<hr></hr>WINNER<hr></hr>";
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}

the echo line never happens (meaning obviously, http_x is never being
sent)

Edited by madninjaskillz - 27 June 2010 at 5:29am
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 27 June 2010 at 8:35am

Hello,
I’ve responded you by E-Mail. Please check your inbox.
Thanks.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version