Rewrite http://domain.com/~user to http://user.domain.com

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

Rewrite http://domain.com/~user to http://user.domain.com

Postby Cloak » Sat Aug 24, 2002 4:08 pm

How exactly can I do this globally? I figured out specifically how to do it:

RewriteEngine on
RewriteBase /~cloak
RewriteRule ^(.*)$ http://cloak.domain.com/$1

That works for the user 'cloak' but obviously not for anyone else.

Thanks.
Cloak
 

Re: Rewrite http://domain.com/~user to http://user.domain.co

Postby Guest » Thu Aug 29, 2002 1:21 am

Cloak wrote:How exactly can I do this globally? I figured out specifically how to do it:

RewriteEngine on
RewriteBase /~cloak
RewriteRule ^(.*)$ http://cloak.domain.com/$1

That works for the user 'cloak' but obviously not for anyone else.

Thanks.


Have you tried this:

RewriteEngine on
RewriteRule ^/~([^/])+/(.*)$ http://$1.domain.com/$2

The ([^/])+ should translate to "match anything that is not a slash" if my regexp knowledge is not entirely rusty. :)

Maybe you need an extra [R] behind the rule.
Guest
 

Postby cloak » Thu Aug 29, 2002 11:10 am

I thought that should work as well, but it doesn't seem to. It just sits there not doing anything...

The rewrite log gives me this:

65.165.xxx.xx - - [29/Aug/2002:06:11:18 -0600] [domain.com/sid#81e8198][rid#82cf8e0/initial/redir#2] (1) [per-dir /home/cloak/public_html/] pass through /home/cloak/public_html/index.php

Granted, it is going to the same directory, but I wanted the URL in the browser to change over.

Really don't understand what I'm missing here.

Cya,
Cloak
cloak
 


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 112 guests

cron