Welcome to WebmasterWorld Guest from 23.20.230.24

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)

10+ Year Member



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)

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



> 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)

10+ Year Member



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

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



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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month