Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site2.com$
RewriteRule (.*) [site2.site1.com...]
how do i make it appear that the browser is actually at site2.com (in the address bar) i've tried adding [L] and [R] to the ends of the rule (i'm not actually sure what they do)
ANY SUGGESTIONS?
Here's a link to the mod_rewrite documentation [httpd.apache.org]. You can find out all about [R] and [L] flags there.
Jim
my current code works, but it shows the redirect change in the address window
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site2.com$
RewriteRule (.*) [site2.site1.com...] [R]
example:
if i had a site foo.com and a parked domain bar.com
accessing foo.com/whatever would be unaffected,
accessing bar.com would be sent to bar.foo.com
accessing bar.com/whatever would be sent to bar.foo.com/whatever
a little confusing, but i hope this helps
all i need to find out how to do is to redirect the page without it displaying in the address bar
i suppose if this can't be done with just mod_rewrite, there are alternatives using mod_rewrite in addition to PHP, but i would prefer to avoid that
This all depends on how your domains are mapped to your server, so you may want to investigate your DNS records and any "parking" or "pointing" you still have in place. Get rid of all the parking and pointing and point the domains to your IP address using DNS A records only. Then make sure the server configuration does not do an external redirect from site2 to site1. I suspect that's what has caused this mess in the first place -- You've got a parked or pointed domain that is doing a 301/302 redirect. Or possibly, you've got code in /home/user/www/.htaccess that is doing this.
As a matter of fact, if the domains were pointed to the same root directory, you wouldn't even have this problem.
The key to a silent redirect is that the domains must be hosted on the same server in a directory in or below the directory of the code that is doing the redirect. Or the redirect code needs to be in httpd.conf - the server configuration file.
The general form of an internal (silent) redirect is:
RewriteRule ^page1\.html$ /page2.html [L]
No domain name can be specified, otherwise it will be an external (visible) redirect. So, in order to do it, the 'domains' must be in the filesystem below the redirect code.
There are work-arounds involving symlinks and such, but they always turn into spaghetti-balls and cause more problems later. Better to fix the problem by simplifying rather than by complicating...
I hope this makes sense.
Jim