tags:

views:

31

answers:

3

I'd like to know if it is possible to do this:

To keep the root clean of all files, I want to put everything under a sub-directory (index.php, .htaccess,...). Is it possible to configure a rule in .htaccess which resides in this sub-directory to redirect from root directory to index.php which also resides in the sub-directory ?

Then what would be the syntax for .htaccess ?

+1  A: 

No. The rules in the subdirectory will only be used if a request is mapped to a path that includes said subdirectory.

To achieve this, you would have to put a rewrite rule either in httpd.conf or in the parent directory.

Artefacto
+1  A: 

A .htaccess file has effect only in/on :

  • The directory that contains it
  • The sub-directories of that directory.

So, no, you cannot have a .htaccess in a directory, that will impact what's in it's parent directory : Apache will not even see that .htaccess file.


If you want something like that, you'll have to put it at a higher-level ; either :

  • In a .htaccess file in the parent-directory (which you don't want to do, it seems)
  • Or directly in Apache's configuration -- in the configuration of your VirtualHost, for example.
Pascal MARTIN
+1  A: 

Just change your DocumentRoot to the different directory in httpd.conf, or /etc/apache2/sites-available/your-site, or similar

Jhong