User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Apache mod_rewrite woes Page [1]  
joe17669
All American
22728 Posts
user info
edit post

Hi,

For about a year now I've been running a personal webserver on my home computer (actually a spare) and have recently signed up with a web host due to increased need for more bandwidth and reliability. While in the transition to this new host, I was trying to figure out how to use mod_rewrite to redirect the traffic to my new server.

I have the following in my root .htaccess file:


RewriteEngine on
RewriteRule ^/(.+) http://www.newserver.com/$1 [R]


I saw several examples of this code on the Web and have not had much luck getting it to work. I know the module is enabled because I can do other simple rewrite commands like

RewriteRule ^oldfile\.html$ /newfile.html [L]


Any ideas? This is Apache 1.3.33 on Windows 2000. Thanks

10/3/2005 7:41:24 PM

lilbirdey
Starting Lineup
55 Posts
user info
edit post

With the rule that you have listed, the URL http://www.oldserver.com/ will not be redirected, but http://www.oldserver.com/foo should be. Try changing your rule to


RewriteRule ^/(.*) http://www.newserver.com/$1 [R,L]


The difference is the '*" (zero or more matches) versus the '+' (one or more matches). The extra "L" at the end of the rule shouldn't matter, but it is more correct (this is the Last rule you will apply to any match).

[Edited on October 4, 2005 at 9:22 AM. Reason : can't format html, duh]

[Edited on October 4, 2005 at 9:22 AM. Reason : more formatting]

10/4/2005 9:21:09 AM

joe17669
All American
22728 Posts
user info
edit post

You are a lifesaver. Thank you

10/4/2005 2:10:18 PM

 Message Boards » Tech Talk » Apache mod_rewrite woes Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.