help me with redirect please

New to mod_rewrite? This is a good place to start.

Postby yakov » Sat Oct 27, 2001 3:42 am

I want to establish a hidden redirect from
http://www.rusmedserv.com/forums/ to http://www.rusmedportal.com/forums/archive/
using mod_rewrite. Help me please.

Thanks in advance.
yakov
 
Posts: 4
Joined: Fri Oct 26, 2001 4:00 pm
Location: Russia

Postby Brett » Sat Oct 27, 2001 9:06 am

If I understand your post correctly, you want to create a dynamic mirror. See:
http://www.engelschall.com/pw/apache/rewriteguide/#ToC26

<font size=-1>[ This Message was edited by: Brett on 2001-10-27 13:07 ]</font>
Brett
 
Posts: 82
Joined: Tue Jul 10, 2001 4:00 pm
Location: yohost.com

Postby yakov » Sat Oct 27, 2001 10:27 am

Thanks, Brett.
Yes, you're right. I uploaded the following .htaccess in http://www.rusmedserv.com/forums/

RewriteEngine on
RewriteBase /forums/
RewriteRule ^forums/(.*)$ http://www.rusmedportal.com/forums/archive/$1 [P]

It doesn't work for me: no redirect at all...
yakov
 
Posts: 4
Joined: Fri Oct 26, 2001 4:00 pm
Location: Russia

Postby Brett » Sat Oct 27, 2001 2:11 pm

Hi Yakov,

It doesn't work for me, either ... unless I change the [P] to an [R], which isn't really what you want.

Here's one way to do it, though:

Make a PHP file, forum.php, containing the following code:
<?php
readfile ("http://www.rusmedportal.com/forums/archive$QUERY_STRING");
?>

Then include the following in your .htaccess file:
RewriteEngine on
RewriteRule ^forums(.*)$ forum.php?$1

Voila! (Works for me, anyway.)
Brett
 
Posts: 82
Joined: Tue Jul 10, 2001 4:00 pm
Location: yohost.com

Postby yakov » Sun Oct 28, 2001 12:43 am

I sent you a PM.
yakov
 
Posts: 4
Joined: Fri Oct 26, 2001 4:00 pm
Location: Russia

Postby Brett » Sun Oct 28, 2001 7:54 am

Hi Yakov,

Actually, it IS working, kind of. Try this:
http://www.rusmedserv.com/forums/forums/
But, there are a few things that aren't working as expected.

(1) I was assuming that you would place the forum.php and .htaccess files in your main directory, not in the forums directory. (You can put them in the forums directory, but you'll need to change the code a little bit.)

(2) Important note: "Versions prior to PHP 4.0.5 do not handle HTTP redirects. Because of this, directories must include trailing slashes." Your server appears to be running PHP 3, so the trailing slashes aren't being handled correctly.

(3) For some reason, URL's such as http://www.rusmedportal.com/forums/archive/5/ are actually returning a 404 code (even though they display the document), so PHP does not display the document. You can verify the 404 code using WebSniffer.

(4) The links in the rusmedportal.com documents start with a slash, so you end up with an extra "archive/" in the URL. You can deal with this by changing either the PHP code or the mod_rewrite code.
Brett
 
Posts: 82
Joined: Tue Jul 10, 2001 4:00 pm
Location: yohost.com

Postby yakov » Tue Oct 30, 2001 11:58 am

Thank you so much!
yakov
 
Posts: 4
Joined: Fri Oct 26, 2001 4:00 pm
Location: Russia


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 24 guests

cron