Welcome to WebmasterWorld Guest from 54.167.86.211

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess - always redirect to https for subdirectory

https redirect for subdirectory

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

New User

10+ Year Member

joined:Aug 1, 2004
posts:34
votes: 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.

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

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 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

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

New User

10+ Year Member

joined:Aug 1, 2004
posts:34
votes: 0


RewriteEngine on
RewriteCondition %{SERVER_PORT} !^443$
RewriteRule ^/order/(.*)$ [maindomain.com...] [R,L]
11:31 pm on Aug 7, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 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