Forum Moderators: phranque
For example, www.sitea.com/siteb or site.com/siteb shoud re-direct to www.siteb.com
This is my vhost entry
<VirtualHost 211.111.111.11:80>
ServerName sitea.com
ServerAlias www.sitea.com
DocumentRoot /home/sitea/public_html
ProxyPass / [servera.hosting.com:8080...]
ProxyPassReverse / [servera.hosting.com:8080...]
</VirtualHost>
I have set RewriteEngine on in my httpd.conf and have tried changing the vhost configuration as follows;
<VirtualHost 211.111.111.11:80>
ServerName sitea.com
ServerAlias www.sitea.com
DocumentRoot /home/sitea/public_html
RewriteRule ^site.com/siteb$ www.siteb.com
ProxyPass / [servera.hosting.com:8080...]
ProxyPassReverse / [servera.hosting.com:8080...]
</VirtualHost>
However this isn't working and I just get a page not found error. Can anyone please advise if and where I'm going wrong? Thank you.
Thanks for your response. I tried modifying the URL re-write as follows;
RewriteCond %{HTTP_HOST} ^site.com/siteb$\.
RewriteRule ^/(.*) [siteb.com...] [P]
But still not working. Can you advise what the problem is?
RewriteCond %{HTTP_HOST} ^(www\.)?sitea\.com
RewriteRule ^/siteb/(.*)$ http://www.siteb.com/$1 [R=301,L]
Be sure to redirect to the canonical hostname of SiteB -- Pick either www.siteb.com or siteb.com, and be consistent to avoid duplicate-content problems. If you are not the owner of SiteB, then ask them what their canonical domain preference is.
Jim
You might look into reverse proxying the request to the other server, or internally rewriting it if the two domains share filespace on the same server. Mod_rewrite can do external redirects, proxy throughputs, and internal rewrites, depending on the syntax you specify.
Be aware that a request proxied to another machine will appear to that second machine as originating from the first server, not from the client. This makes the server access logs on the back-end server kind of useless; To overcome this, the front-end server can be configured to send the originating IP address with an HTTP X-Forwarded-For header, and the back-end server can be configured to use that header instead of Remote_Addr for logging purposes.
There are several useful resources cited in our Forum Charter, the Apache mod_rewrite documentation and the Apache URL Rewriting Guide among them. These are worth a thorough read. Also, we have several tutorials in the Apache section of the WebmasterWorld Library. See the links at the top of each page here.
As for printed books, there are a few good ones available through Amazon, B&N, etc. on-line.
Jim