views:

17

answers:

1

Hi,

I need to write a rule to redirect a page to a parent directory in a .htacces file.

For instance, this is my files system :

- a-directory
- another-directory
-- a-file

i've got a virtualhost which is a pointer to "a-directory"

so when i go to http//my-virtualhost/a-file, i need to go back to the parent directory and open "a-file" in the directory "another-directory".

First at all, is that possible ? Then, how can i write this ?

Thank you!

A: 

Out of curiosity, is there a reason you wouldn't just point your virtual host to "another-directory" to begin with, if everything is just redirecting there?

Assuming you can put a .htaccess file above "a-directory", it would just be a matter of doing something like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^a-directory/(.*) another-directory/$1

If for whatever reason the .htaccess file couldn't go there, you'd need something more geared for this kind of task, like mod_alias.

Tim Stone