10

I have a htacces file in my root folder with some basic code in it. But I want that all those instructions get ignored in the directory "voxelforum.com". How can I achive this?

Thanks!

1

4 Answers 4

19

Oddly, you may first need to turn off rewrite and then put it on again

Put a .htaccess file in the subfolder and add these 2 lines:

RewriteEngine Off
RewriteEngine On

Add your rewrite rules below


This worked for me whereas simply adding RewriteEngine On did not.

2
  • This was the case for me as well. I need both Off and On.
    – jackrugile
    May 17, 2016 at 22:09
  • Glad it helped though don't understand why the trigger off was required first. Strange one, I still have my .htaccess this way :/ May 19, 2016 at 18:38
10

It depends on what rules you want to override:

If you want to disable rewrite rules, then you can put a .htaccess file in the subfolder that contains RewriteEngine On, and the rules for the parent folder will be disabled (technically, replaced).

Similarly, if you want to disable authentication for a subfolder, you can create a .htaccess that contains Satisfy Any.

.htaccess rules cascade upwards, so Apache will look for a .htaccess file in the current folder and use the rules for it, then check the parent folder, etc.

5
  • I'll try this one. Seems logical.
    – Martijn R
    Oct 12, 2012 at 11:43
  • 1
    I started doing all my htaccess rules in my conf file and eliminated htaccess files. I believe there is a performance boost to be had doing this as well. Oct 7, 2014 at 19:50
  • 1
    @MichaelDeMutis That's correct, for maximum performance benefit don't forget to disable htaccess files altogether so Apache doesn't even look for them. I would say this is an option that's not available to everyone, though, as not every developer deploys to an environment that they control.
    – Kelvin
    Oct 10, 2014 at 13:44
  • @KevinMackay What is the procedure to disable it completely from Apache? Oct 12, 2014 at 7:05
  • @MichaelDeMutis You can disable htaccess completely by setting AllowOverride to None - see httpd.apache.org/docs/current/howto/htaccess.html
    – Kelvin
    Oct 13, 2014 at 9:48
2

Put a .htaccess file in the subfolder and add this line only:

RewriteEngine On

1

Remove your htaccess from your root folder and move it in your subfolders. As far as I know there is no way to disable htaccess for the root folder.

EDIT: check AllowOverride

4
  • But I want my htacces in my root folder (main website) but I don't want it in my sub-folder (secondary website).
    – Martijn R
    Oct 11, 2012 at 22:49
  • But you're saying it isn't possible?
    – Martijn R
    Oct 11, 2012 at 22:50
  • Ah, sorry, not sure about that but check the AllowOverride directive Oct 11, 2012 at 22:58
  • AllowOverride is used to determine what directives are allowed within a .htaccess file - eg, if you put "AllowOverride None" in your apache configuration, .htaccess files would be disabled completely. Though the name suggests otherwise, it doesn't affect whether .htaccess files can override each other. That said, you could put <Directory /path/to/subfolder>AllowOverride None</Directory> in your apache/vhost configuration, which might disable the parent folder's .htaccess rules. It's certainly worth a try.
    – Kelvin
    Oct 11, 2012 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.