homepage Welcome to WebmasterWorld Guest from 54.227.67.210
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess - always redirect to https for subdirectory
https redirect for subdirectory
bendj




msg:1501893
 3:42 am on Aug 6, 2004 (gmt 0)

Is there a way to have a redirect only active for a subdirectory?

If a user goes to [domain.com...]
I want it to always redirect to https, but only for that directory.

I tried creating a .htaccess file with a rewrite in the subdirectory but couldn't get it to work. Does apache merge all the htaccess files? Could this be done form the main htaccess file?

Thank you.

 

jdMorgan




msg:1501894
 1:09 am on Aug 7, 2004 (gmt 0)

> Does apache merge all the htaccess files?

Apache processes them in order as it traverses the driectory structure to reach the requested resource.

> Could this be done form the main htaccess file?

Yes, certainly, if it can be done at all.

> I tried creating a .htaccess file with a rewrite in the subdirectory but couldn't get it to work.

Post your code, and we'll try to help you get it working.

Jim

bendj




msg:1501895
 10:46 pm on Aug 7, 2004 (gmt 0)

RewriteEngine on
RewriteCondition %{SERVER_PORT} !^443$
RewriteRule ^/order/(.*)$ https://www.maindomain.com/order/$1 [R,L]

jdMorgan




msg:1501896
 11:31 pm on Aug 7, 2004 (gmt 0)

Is /order the name of the subdirectory? If so, remove it from the RewriteRule pattern, because it will be stripped by the time this code is processed in that subdirectory.

In .htaccess in the subdirectory named /order :

RewriteEngine on
RewriteCondition %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.maindomain.com/order/$1 [R=301,L]

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved