UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Applications

Reply
 
Thread Tools Rate Thread Display Modes
Old 12th May 2008, 11:56 AM   #1 (permalink)
lobstu
Registered User
 
Join Date: May 2008
Posts: 5
mod_rewrite + ensure SSL gotcha

Hi there,

I have the following rule configured for a site of mine:

RewriteCond %{SERVER_PORT} !443$
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

As you can see, it ensures that all requests are forwarded to the SSL version of themselves. Now I want to exclude a folder in the root of the site, 'software', from this rule. I tried this and some variants:

RewriteCond %{SERVER_PORT} !443$
RewriteCond %{REQUEST_URI} !^/software(.+)$
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

But for some gosh-darn reason it insists on forwarding all the /software/* requests to https.

I've googled, I've read the manual, the cheat sheet on ilovejackdaniels.com, and I just don't know what else to do. I would love to configure RewriteLog but as this site is on a shared host I just don't have the capability.

Any takers? The site in question will be moving to UnitedHosting shortly.

Thanks
lobstu
lobstu is offline   Reply With Quote
Old 12th May 2008, 12:54 PM   #2 (permalink)
MrBen
Munky!
 
MrBen's Avatar
 
Join Date: Sep 2003
Location: nr Woking, England
Posts: 2,551
I do something similar on one of my sites. The following should work. You need to exclude /software/ from the first rewrite. Each rule uses [L] which means last rule - i.e. don't bother processing any more.

Code:
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/software/.*$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} ^/software/.*$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Ben
__________________
The impossible I can do today, miracles take a little longer

Veterinary Practice Management System by SoftFooding
Internet Data Usage Calculator: Estimate your monthly bandwidth usage for your Internet connection.
Little Red: Nordic Style Rye Bread
MrBen is offline   Reply With Quote
Old 12th May 2008, 01:04 PM   #3 (permalink)
lobstu
Registered User
 
Join Date: May 2008
Posts: 5
Thanks once again Ben

Is there a definitive how-to-use-mod_rewrite site/page somewhere?

I'd love a narrative-style but thorough tut on apache/mod_rewrite configuration.

It appears to be incredibly versatile!
lobstu is offline   Reply With Quote
Old 12th May 2008, 01:42 PM   #4 (permalink)
MrBen
Munky!
 
MrBen's Avatar
 
Join Date: Sep 2003
Location: nr Woking, England
Posts: 2,551
No problem. I've just stumbled through it as required and picked up the knowledge as I went.

I Love JD is pretty useful, but otherwise I just keep Googling until I've found what I wanted.

Ben
__________________
The impossible I can do today, miracles take a little longer

Veterinary Practice Management System by SoftFooding
Internet Data Usage Calculator: Estimate your monthly bandwidth usage for your Internet connection.
Little Red: Nordic Style Rye Bread
MrBen is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 12:05 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309