Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Applying Apache <Directory> rules to all subdirectories except 2.

Posted on 2014-10-22
3
Medium Priority
?
222 Views
Last Modified: 2014-12-15
Hi

What is the simplest way to apply these rules to all sub directories of "C:/Website" except for folders names "images" and "css"

<Directory "C:/Website/*/>">
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Directory>

Running Apache 2.4 on windows server.

Thankyou
0
Comment
Question by:mhdi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 51

Expert Comment

by:Steve Bink
ID: 40398434
The better question is why you would want to.  By forcing content pages to be SSL, and not enforcing the same policy for other resources, your users will likely receive mixed-content warnings in their browser.

Still, if you're sure this is the strategy you want, check out the DirectoryMatch container directive.  The Directory container allows some wildcards, but they will not match a directory separator character.  DirectoryMatch allows for the use of regex patterns, which gives better flexibility.
<DirectoryMatch "^C:/Website/.*(images|css)/">
    # ...
</DirectoryMatch>

Open in new window

0
 

Author Comment

by:mhdi
ID: 40405363
If I did that, how do I ensure the instructions a processed in the correct order?

<DirectoryMatch "^C:/Website/.*/">
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</DirectoryMatch>
<DirectoryMatch "^C:/Website/.*(images|css)/">
   RewriteEngine Off
</DirectoryMatch>

Open in new window

0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 40405631
From the docs regarding how these containers are applied and merged:
Apart from <Directory>, each group is processed in the order that they appear in the configuration files. <Directory> (group 1 above) is processed in the order shortest directory component to longest. So for example, <Directory /var/web/dir> will be processed before <Directory /var/web/dir/subdir>. If multiple <Directory> sections apply to the same directory they are processed in the configuration file order. Configurations included via the Include directive will be treated as if they were inside the including file at the location of the Include directive.
0

Featured Post

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question