Вопрос

I've setup a yourls.org (URL shortening service) on a windows 2003 VPS server I have, using ISAPI rewrite. I already have ISAPI rewrite installed and working with Wordpress, so I know that is working. I have used the rules suggested from the page:

http://code.google.com/p/yourls/wiki/htaccess

In my ISAPI rewrite, but the redirects are not working. The page is looping, trying to redirect to itself.

I'm not familiar with Rewrite rules so any help would be appreciated. The rules I've applied are:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (/|\.php|/[^.]*)$  [NC]
RewriteRule ^(.*)$ /yourls-loader.php [L]

I added the third conditional line based on something I found in the wiki of the application.

If anyone could shed any light on why this isn't working, I'd appreciate it.

T

Это было полезно?

Решение

Ok, this took me all day, but I got it working. For anyone interested, there was absolutely nothing wrong with the ISAPI rewrite. The problem was in the code. In a file called yourls-loader.php, there's a line that checks the url, deconstructs it and reconstructs it. The problem is that it always forces the new url into https. If you've no security cert on your server it won't work!!!

//$scheme = ( isset($_SERVER["HTTPS"]) ? 'https' : 'http' );
//$request = str_replace( YOURLS_SITE.'/', '', $scheme . 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$request = str_replace( YOURLS_SITE.'/', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );

The first 2 lines are commented out, this is what was here. As I trust and know how my server is setup (cause I did it myself) I don't feel any need for this check system.

One other thing to be aware of on a Windows system is that you will have to add the suggested Server_URI parse at the start of this file too.

if (isset($_SERVER['HTTP_X_REWRITE_URL'])){
    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}

I hope this helps someone... It's taken me all day to resolve with no online support.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top