tags:

views:

24

answers:

2

I have the following URLs:

  1. www.mydomain.com/client
  2. www.mydomain.com/client/index.php
  3. www.mydomain.com/client/index.php?a=b
  4. www.mydomain.com/client/index.php?a=b&b=c

The following two htaccess files exist:

  • www.mydomain.com/.htaccess
  • www.mydomain.com/client/.htaccess

I want to edit "www.mydomain.com/client/.htaccess" so that if you go to www.mydomain.com/client, that it redirects the user to mydomain.com/client/clientarea.php. In other words, 1 and 2 must redirect to mydomain.com/client/clientarea.php, but 3 and 4 must not.

How do I do that?

+2  A: 

Try this:

RewriteEngine on  
RewriteBase /
RewriteRule ^client$ /clientarea.php [L]
RewriteRule ^client/index.php$ /clientarea.php [L]  
antyrat
+1  A: 

htaccess files are parsed in the order they're discovered, so the top level one (mydomain.com/.htaccess) will be parsed and executed before Apache even considers looking down in the .../client sub-directory. As such, you'd have to modify your rewrite rule to check if the request contains a subdirectory, and NOT process it if one's found.

Marc B