Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

How to properly write mod_rewrite or mod_alias rules for url forwarding

I have a domain (E.g. www.mypersonaldomain.com) and I also write a blog on Xanga.com (E.g. www.xanga.com/myblog

I'd like to use a mod_rewrite or mod_alias rule so that all requests for mypersonaldomain.com are rewritten internally to request www.xanga.com/myblog.  The user experience is that mypersonaldomain.com will always remain visible in the browser's URL bar, even though the internal links on the site point to xanga.com/myblog

Can you please provide me with the mod_rewrite or mod_alias directives how to do that?  And please advise whether that goes in .htaccess, httpd.conf or php.ini.  My site is hosted in a shared environment at my ISP.

  • 2
2 Solutions
What you are asking can only be done trough mod_rewrite or mod_alias if both sites are hosted on the same server.

To preserve your domain name in the address bar you should try frame forwarding. mypersonaldomain.com should return a page to the users that contains a frame with xanga.com/myblog in this case.

example html for frame redirect (place this in index.html or whatever your default document is)t:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<title>My Personal Domain</title>
<frameset rows="100%">
  <frame src="http://www.xanga.com/myblog">
  Please follow <a href="http://www.xanga.com/myblog">link</a>!

If you really only want to achieve this trough apache alone you can try using mod_proxy but all the traffic will go trough your server and eat your bandwidth and your ISP might not be verry happy with that.
gmahler5thAuthor Commented:
How would I configure the mod-proxy solution?
these two directives must be placed into the virtual host definition of mypersonaldomain.com in httpd.conf. mod_proxy must be enabled.

ProxyPass / http://xanga.com/myblog/
ProxyPassReverse /  http://xanga.com/myblog/

This approach will not cache anything locally on your server and all the traffic will go trough your server.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now