help with regex

Topics: Developer Forum, User Forum
May 8, 2010 at 12:15 PM
Edited May 8, 2010 at 12:21 PM


I'd appreciate some help with regex.

I have 2 sites, eg and I want to go to (rewrite, not redirect). My hosting provider added this line for me

RewriteRule  ^/(.*)$            $1 [R=301,L]

But this a redirect, and when I remove the [R=301,L] I get a 404 page not found error. They don't know the regex for this.

Help appreciated.


PS: I need only to go to Other sbdomains should not be rewritten.

May 8, 2010 at 5:14 PM

You're not asking for help on regex.  Regex is the pattern matching language. 
You don't appear to be having trouble with that.

You seem to not get the rewrite vs. redirect thing.  You cannot "rewrite" from one host to another.

To clarify yourself on that, Read the documentation

I think you might want to proxy the request. If so, read the documentation on ProxyPass.


May 8, 2010 at 9:02 PM

Right, to do what you want you *must* do a redirect, as Cheeso said you can't *rewrite* from one host to another as it's an internal host operation.

I think what you really want to do is change your dns record.  Right now you probably have an "A" (authoritative) record for pointing to some actual server IP.  What you should do is change that record to a "C" (alias) record pointing to  Your host provider may use different terms, but they mean the same thing (mine calls it a "Custom DNS console", with "subdomain pointers").

That should do exactly what you want, and is something I do all the time.  If a user types in "" they will end up at "", but the URL address will still show "".

IIRF is a great tool, but it's not the right tool for *everything* ;-).