Topic: Need help with a basic rewrite rule

Me and Apache's documentation, we aren't quite friendly. Si I need help with a small thing.

I have a website app like this : www.website.tld/app/

I want to redirect (with a http 301 code) any URL inside that /app/ repertory to app.website.tld

The trick is, two thing.

First, I would like to pass along the exact URL to the new site, for example www.website.tld/tld/caramba would be app.website.tld/caramba

The second is, I need to target only /app/ from the root of www.website.tld because I have other rewrite rules for other things here.

ANyone has an idea? I'm sure it's simple, but I don't want to screw it up.

2

Re: Need help with a basic rewrite rule

Try this:

RedirectMatch 301 ^/app/(.*)$ http://app.website.tld/$1

Re: Need help with a basic rewrite rule

Thanks, I'll try it.

I got this from several try :

RewriteRule ^app/?(.*)$ http://app\.website\.tld/$1 [QSA,L,R=301]

That seems to work, but it also trigger website.tld/appli for example, and rewrite it as /li on the proper new domain.

Re: Need help with a basic rewrite rule

Yup, yours works better. And I guess (a real wild guess this one) it's slightly less demanding on Apache.

Thanks Bert.

5

Re: Need help with a basic rewrite rule

No problem, running so many sites like I do, rewrite comes in handy when I decide to move things around.