Simple Rewrite Rule?

Topics: Developer Forum, User Forum
Aug 8, 2008 at 3:32 AM
I trying to create a simple rewrite rule for one domain. I basically need every domain to forward to it's alias www subdomain and also keep it's post information.

Example:   domain.com   => www.domain.com
                 domain2.com  => www.domain2.com

I have tried certain attempts.

Can somebody help please? First time filter user.
Aug 8, 2008 at 3:53 AM
basically any url that doesn't start with www.

www should then be added to it.
Coordinator
Aug 8, 2008 at 4:56 AM

Do you want a redirect?

If so, you can do it like this:

RewriteCond %{HTTP_HOST} ^(?!www\.)((domain1|domain2)\.com)$
RewriteRule ^/(.*)$        http://www.%1/$1    [R]

Redirect means the browser gets a response that says "please direct that request elsewhere" and the "elsewhere" says www.domain.com. The browser updates its address bar and re-submits the request. Not sure what happens to HTTP POST data on HTTP response code 301 and 302. But that has nothing to do with the filter.

If you don't want a redirect, then I think you want a Proxy, which is not IIRF.

Aug 8, 2008 at 5:08 AM
This worked beautifully.... Thanks so much!!!!!!!!

By the way, what will be an example of a Proxy, just curious?
Coordinator
Aug 9, 2008 at 12:05 AM

You're welcome.
Keep in mind that IIRF is DonationWare.   http://cheeso.members.winisp.net/IirfDonate.aspx

About the proxy server, this is from wikipedia (http://en.wikipedia.org/wiki/Proxy_server):

In computer networks, a proxy server is a server (a computer system or an application program) which services the requests of its clients by forwarding requests to other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource, available from a different server. The proxy server provides the resource by connecting to the specified server and requesting the service on behalf of the client. A proxy server may optionally alter the client's request or the server's response, and sometimes it may serve the request without contacting the specified server. In this case, it would 'cache' the first request to the remote server, so it could save the information for later, and make everything as fast as possible.

A proxy server that passes all requests and replies unmodified is usually called a gateway or sometimes tunneling proxy.