You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Julian Grunnell <jg...@firstnet.net.uk> on 2002/11/19 14:51:56 UTC

[users@httpd] Mod_rewrite help

Could someone help me with the above pls?

I am trying to use mod_rewrite with this scenario, user enters
www.whatever.com/~fred into browser. And web servers translates this
into www.fred.whatever.com/

I am almost there - I think, below is a copy of of the vhost + details
from the rewrite log.

<VirtualHost 10.10.10.3:80  10.10.11.3:80>
ServerName      www.whatever.com
DocumentRoot    /local/apache1326/htdocs
ScriptAlias     /cgi /local/apache1326/cgi-bin/
ScriptAlias     /cgi-bin /local/apache1326/cgi-bin/
RewriteEngine   on
RewriteLogLevel 9
RewriteLog      /local/apache1326/logs/rewrite.log
RewriteCond     %{REQUEST_URI} ^/~[^.]
RewriteRule     ^/(.*)$ http://www.$1.whatever.com [R]

172.16.12.128 - - [19/Nov/2002:13:33:08 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) init rewrite engine
with requested uri /~bill
172.16.12.128 - - [19/Nov/2002:13:33:08 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (3) applying pattern
'^/(.*)$' to uri '/~bill'
172.16.12.128 - - [19/Nov/2002:13:33:08 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (4) RewriteCond:
input='/~bill' pattern='^/~[^.]' => matched
172.16.12.128 - - [19/Nov/2002:13:33:08 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) rewrite /~bill ->
http://www.~bill.whatever.com
172.16.12.128 - - [19/Nov/2002:13:33:08 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) explicitly forcing
redirect with http://www.~bill.whatever.com
172.16.12.128 - - [19/Nov/2002:13:33:08 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (1) redirect to
http://www.~bill.whatever.com [REDIRECT/302]
172.16.12.128 - - [19/Nov/2002:13:42:16 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) init rewrite engine
with requested uri /~fred
172.16.12.128 - - [19/Nov/2002:13:42:16 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (3) applying pattern
'^/(.*)$' to uri '/~fred'
172.16.12.128 - - [19/Nov/2002:13:42:16 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (4) RewriteCond:
input='/~fred' pattern='^/~[^.]' => matched
172.16.12.128 - - [19/Nov/2002:13:42:16 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) rewrite /~fred ->
http://www.[^~]~fred.whatever.com
172.16.12.128 - - [19/Nov/2002:13:42:16 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) explicitly forcing
redirect with http://www.[^~]~fred.whatever.com
172.16.12.128 - - [19/Nov/2002:13:42:16 +0000]
[www.whatever.com/sid#e8bc8][rid#10ff10/initial] (1) redirect to
http://www.[^~]~fred.whatever.com [REDIRECT/302]

So it works but it is putting a "~" in the redirect and I get
www.~fred.whatever.com instead of www.fred.whatever.com.

Any help would be appreciated. Thanks - Julian.

Julian Grunnell
3rd Line Technical Support
E: jgrunnell@firstnet.net.uk
T: 0870 1278008 F: 0870 1278009
DDI: 0113 292 7739
http://www.firstnet.net.uk <http://www.firstnet.net.uk/> 

Firstnet Services Ltd
Registered Office: Peregrine House, Gelderd Close, Leeds, LS12 6DS 
Registered in England no. 3152569

This email is subject to: http://HYPERLINK
"outbind://104-000000000F5A449BBF7B8C47A7B46D685B7CE2640700F03FBCC63B1BE
94F9F9B3EE69601627A0000010E0A370000F03FBCC63B1BE94F9F9B3EE69601627A00000
1CFE0180000/www.firstnet.net.uk/disclaimer.html"www.firstnet.net.uk/disc
laimer.html <http://HYPERLINK > 



Re: [users@httpd] Mod_rewrite help

Posted by software <so...@polin.it>.
Mod_rewrite helpHi!

You could try

RewriteRule     ^/(.*)$ http://www.%1.whatever.com [R]

-- Andrea
  ----- Original Message ----- 
  From: Julian Grunnell 
  To: apache-users 
  Cc: apache-yahoo 
  Sent: Tuesday, November 19, 2002 2:51 PM
  Subject: [users@httpd] Mod_rewrite help


  Could someone help me with the above pls? 

  I am trying to use mod_rewrite with this scenario, user enters www.whatever.com/~fred into browser. And web servers translates this into www.fred.whatever.com/

  I am almost there - I think, below is a copy of of the vhost + details from the rewrite log. 

  <VirtualHost 10.10.10.3:80  10.10.11.3:80> 
  ServerName      www.whatever.com 
  DocumentRoot    /local/apache1326/htdocs 
  ScriptAlias     /cgi /local/apache1326/cgi-bin/ 
  ScriptAlias     /cgi-bin /local/apache1326/cgi-bin/ 
  RewriteEngine   on 
  RewriteLogLevel 9 
  RewriteLog      /local/apache1326/logs/rewrite.log 
  RewriteCond     %{REQUEST_URI} ^/~[^.] 
  RewriteRule     ^/(.*)$ http://www.$1.whatever.com [R] 

  172.16.12.128 - - [19/Nov/2002:13:33:08 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) init rewrite engine with requested uri /~bill

  172.16.12.128 - - [19/Nov/2002:13:33:08 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (3) applying pattern '^/(.*)$' to uri '/~bill'

  172.16.12.128 - - [19/Nov/2002:13:33:08 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (4) RewriteCond: input='/~bill' pattern='^/~[^.]' => matched

  172.16.12.128 - - [19/Nov/2002:13:33:08 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) rewrite /~bill -> http://www.~bill.whatever.com

  172.16.12.128 - - [19/Nov/2002:13:33:08 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) explicitly forcing redirect with http://www.~bill.whatever.com

  172.16.12.128 - - [19/Nov/2002:13:33:08 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (1) redirect to http://www.~bill.whatever.com [REDIRECT/302]

  172.16.12.128 - - [19/Nov/2002:13:42:16 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) init rewrite engine with requested uri /~fred

  172.16.12.128 - - [19/Nov/2002:13:42:16 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (3) applying pattern '^/(.*)$' to uri '/~fred'

  172.16.12.128 - - [19/Nov/2002:13:42:16 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (4) RewriteCond: input='/~fred' pattern='^/~[^.]' => matched

  172.16.12.128 - - [19/Nov/2002:13:42:16 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) rewrite /~fred -> http://www.[^~]~fred.whatever.com

  172.16.12.128 - - [19/Nov/2002:13:42:16 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (2) explicitly forcing redirect with http://www.[^~]~fred.whatever.com

  172.16.12.128 - - [19/Nov/2002:13:42:16 +0000] [www.whatever.com/sid#e8bc8][rid#10ff10/initial] (1) redirect to http://www.[^~]~fred.whatever.com [REDIRECT/302]

  So it works but it is putting a "~" in the redirect and I get www.~fred.whatever.com instead of www.fred.whatever.com. 

  Any help would be appreciated. Thanks - Julian. 

  Julian Grunnell 
  3rd Line Technical Support 
  E: jgrunnell@firstnet.net.uk 
  T: 0870 1278008 F: 0870 1278009 
  DDI: 0113 292 7739 
  http://www.firstnet.net.uk 

  Firstnet Services Ltd 
  Registered Office: Peregrine House, Gelderd Close, Leeds, LS12 6DS 
  Registered in England no. 3152569 

  This email is subject to: http://HYPERLINK "outbind://104-000000000F5A449BBF7B8C47A7B46D685B7CE2640700F03FBCC63B1BE94F9F9B3EE69601627A0000010E0A370000F03FBCC63B1BE94F9F9B3EE69601627A000001CFE0180000/www.firstnet.net.uk/disclaimer.html"www.firstnet.net.uk/disclaimer.html