.htaccess redirect http --> https

Problems with the Windows version of XAMPP, questions, comments, and anything related.

.htaccess redirect http --> https

Postby 2108 » 25. April 2008 14:59

Hi guys,

im trying to redirect protocols from http to https on one of my localhost test sites.

im running my site on: http://localhost

i want the protocol to be changed automatically (i.e. redirect) to https when going on the page cart-conf.php so:

https://localhost/cart-conf.php

whenever i navigate to that page

any solution for this? ive tried google and a new other places but no luck :(

any help appreciated

thanks :D
2108
 
Posts: 6
Joined: 25. April 2008 14:38

Postby 2108 » 26. April 2008 21:37

anyone know? :?
2108
 
Posts: 6
Joined: 25. April 2008 14:38

Postby maxnorris » 28. April 2008 18:54

Could do a redirect with your .htaccess file. I'm typing this off the top of my head, but should be pretty close; might need to Google it to be sure though. Edit this to suit your needs.

This is assuming you have the rewrite module running in Apache.

Code: Select all
RewriteEngine on

# Redirect /directory_or_file_name to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} /directory_or_file_name
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]


That should pick up any references to a particular file or directory, and if it's connecting with regular HTTP, it'll rewrite the URL to connect via HTTPS instead. Check the Apache manual on the rewrite module for more info.
maxnorris
 
Posts: 17
Joined: 21. August 2006 06:51


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 69 guests