redirect root without redirecting sub-directories

New to mod_rewrite? This is a good place to start.

redirect root without redirecting sub-directories

Postby volksmenner » Tue Jun 16, 2009 2:28 am

hello. in a nutshell, here is what i wish to do...

1. getstartedtoday.biz redirects to affiliateA.com

2. getstartedtoday.biz/blog (or any number of sub-directories) does not redirect

3. getstartedtoday.biz/productB redirects to affiliateB.com

so redirect the root domain to site A without redirecting all sub-directories, however, still having the ability to redirect specified sub-directories.

sorry i posted here waiting for approval.
volksmenner
 
Posts: 4
Joined: Wed Jul 09, 2008 3:41 pm

Postby richardk » Tue Jun 16, 2009 10:30 am

1. getstartedtoday.biz redirects to affiliateA.com

Just example.com/ or any file in the document root (eg. example.com/afile.ext)?
And the same for /productB. What about /productB/?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^productB$ http://example.net/? [R,L]
RewriteRule ^$         http://example.org/? [R,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby volksmenner » Tue Jun 16, 2009 2:20 pm

actually, how would it work in either case?

redirect example.com/ (all files in document root)
redirect example.com/productB/ (all files in document root)

and also...

redirect example.com/ (only. no files or folders)
redirect example.com/productB/ (only. no files or folders)

the latter example is what i originally had in mind. but i can imagine i might have use for both instances.
volksmenner
 
Posts: 4
Joined: Wed Jul 09, 2008 3:41 pm

Postby richardk » Tue Jun 16, 2009 3:33 pm

redirect example.com/ (all files in document root)
redirect example.com/productB/ (all files in document root)

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^productB(/.*)?$ http://example.net/? [R,L]
RewriteRule ^[^/]*$          http://example.org/? [R,L]


redirect example.com/ (only. no files or folders)
redirect example.com/productB/ (only. no files or folders)

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^productB/?$ http://example.net/? [R,L]
RewriteRule ^$          http://example.org/? [R,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 102 guests

cron