Forum Moderators: phranque

Message Too Old, No Replies

Global Redirect - Rewrite domain as path

Global Redirect Rewrite domain as path

         

falcondrum

5:42 pm on Mar 29, 2004 (gmt 0)

10+ Year Member



I'm trying to write a GLOBAL rule, for all virtual sites that redirects a fixed /path to another domain and rewrites the original domain (without the tld) as the new path.

1 - Where in the httpd.conf should the be put? inside a NameVirtualHost ****.****.****.xxx or <Virtual Host xxx.xxx.xxx.xxx>, since there are several virt ip addresses

2 - what is the correct format? This is what I tried inside a NameVirtual Host, but the webserver choked:

the visitor types: [abc.com...] or anything.com/xyz
they should go to: [example.com:123...]

RewriteEngine On
RewriteBase /xyz
RewriteRule (.*) [example.com:123...] [R=301,L]

Thanks!

jdMorgan

6:39 pm on Mar 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When the server chokes, what does it write in its error log?

Is example.com (the new destination) also hosted on this machine?

Jim

falcondrum

10:07 pm on Mar 29, 2004 (gmt 0)

10+ Year Member



I couldn't find anything in the error log; but the server stopped serving pages.

jdMorgan

2:33 pm on Mar 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since you're using an external redirect, your mod_rewrite code will be processed repeatedly, each time a redirect is done. This leads to an "infinite loop."

Because of this, you need to exclude www.example.com:123 so that it is not repeatedly rewritten, putting your server into a loop. Use RewriteCond and the {HTTP_HOST} and {SERVER_PORT} variables to prevent www.example.com:123 from being rewritten.

Jim

falcondrum

3:12 pm on Mar 30, 2004 (gmt 0)

10+ Year Member



I'm not sure of the complete syntax and where in the httpd.conf file to put this. I used to use:

REDIRECT /xyz [example.com:123...]

within every <VirtualSite> that required it. Then after we reinstalled the server, I figured a global redirect would be less maintenance....but where to put it and what syntax?

Thanks,
/\/\att