Solved

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

Posted on 2014-10-22
3
209 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 500 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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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