tags:

views:

35

answers:

2

I have the following .htaccess file in a directory:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.mysite.com/launch [R,L] 
DirectoryIndex index.html

Basically, this forces any and all pages below mysite.com/launch to an SSL version of https://www.mysite.com/launch/index.html.

However, for a single sub-directory under /launch I need to be able to allow access without user being redirected.

For example, if they navigate to www.mysite.com/launch/files/photos, then they should be able to access individual files inside the /photos directory.

Do I use another .htaccess file inside the /photos directory, or do I modify the existing .htaccess file in the /launch directory?

+1  A: 

Just add another RewriteCond above your rules, like so:

# Put this above the existing RewriteCond
RewriteCond %{REQUEST_URI} !launch/files/photos
...
aefxx
A: 

i used something like that.

RewriteRule ^(?!intranet/|cv/)(.+)$ somedirname/$1 [L]
RewriteRUle ^$ somedirname/ [L]

so when mysite.com/intranet is called it goes into the folder intranet or when mysite.com/cv is called it goes into the cv folder

but in this case when no subdir is called it forces to go into 'somedirname'

of course you can change the last rewriterule to RewriteRule ^(.*)$ to https://www.mysite.com/launch [R,L]

putting the other rewriterule on top for checking it is not the directory they can access

so you end up with something like this:

RewriteCond %{HTTPS} !=on
RewriteRule ^(?!subdir1/|subdir2/)(.+)$ launch/$1 [L]
RewriteRule ^(.*)$ https://www.mysite.com/launch [R,L] 
DirectoryIndex index.html

now www.mysite.com/subdir1 and www.mysite.com/subdir2 can be opened in the browser

FLY