mod_rewrite is driving me insane!

Discuss practical ways rearrange URLs using mod_rewrite.

Postby raoul » Thu Aug 23, 2001 7:25 am

Hi,
Ok, I am trying to use mod_rewrite to persist session ids with PHP. The site
is at: http://rumour.roundlinux.com/site and when you connect this is
changed to: http://rumour.roundlinux.com/<session-id>/site where
<session-id> is an 32 character alpha-numeric md5 hash. So, I want
mod_rewrite to rewrite urls with the session id inside to urls without.
Currently, I am using this in an .htaccess file in the directory above
/site:
RewriteEngine On
RewriteBase http://rumour.roundlinux.com/site/
RewriteRule rumour.roundlinux.com/(.*)/site /www/rumour/site/$2

At the moment I am getting a 500 server error. Is there an easy way I can
tell if mod_rewrite is fuctioning on the server? What am I doing wrong? I
know the regex is very rough, but I just want to get this going at the
moment. I have read a few things about mod_rewrite on the internet, but I
still hardly understand how the damn thing works.

Any help gratefully received...

Raoul Parekh
raoul
 
Posts: 2
Joined: Wed Aug 22, 2001 4:00 pm

Postby Brett » Thu Aug 23, 2001 2:58 pm

Hi Raoul,

Thanks for posting on my little forum! It was getting lonely in here. :)25 It's true that many hosts do not support mod_rewrite. You might want to see if "RewriteEngine on", by itself, generates a 500 error ... or ask your host if they support mod_rewrite.

Also, I must admit that I haven't had much luck using RewriteBase for much of anything. (Hey, I'm not claiming to be an expert at this. I started this forum in part because, to borrow your phrase, mod_rewrite is driving me insane.)

I think the following will do more-or-less what you want:
Code: Select all
RewriteEngine on
RewriteRule ^(.*)/site site/?$1

This rewrites any URL beginning with yourdomain.com/anygibberish/site as yourdomain.com/site/?anygibberish ... so that you can use $QUERY_STRING to access the, uh, gibberish. (I haven't tested it on a subdomain, but I think it will work the same way.)

Note: I might be missing something, but it seems to me that it would be easier to use PHP's built-in session support.

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

Postby raoul » Fri Aug 24, 2001 3:40 am

Thanks for the reply!
I did ask my host whether they supoprted it, but I got a 'don't know, fill in the support form'. One month ago I asked a question through this support form and I haven't yet received a reply, so I don't really see the point of doing that. I will try what you say about just using rewriteengine on, but I am going away for a few days now, so it will have to wait till I get back.

I don't really want to rewrite it as the query string as part of my reasons for doing the sessions this way is that I don't want to have to append the session id manually to each link, so I really need to rewrite it in the way I said before..

Thanks again, I hope we can resolve this soon...

Raoul

<font size=-1>[ This Message was edited by: raoul on 2001-08-24 07:45 ]</font>
raoul
 
Posts: 2
Joined: Wed Aug 22, 2001 4:00 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 5 guests

cron