Jump to content

.htaccess and https and URL routing


tcnjdeluca

Recommended Posts

I am attempting set up my server so I can have both URL routing and direct one or two pages to https automatically. 

 

I set my .htaccess to the following and redirected all my pages to https, but broke some of my URL routing.

	Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . homepage.php
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.classchatterlive.com/$1 [R,L]
AddType application/x-httpd-php .xml

 

I do not need every page on the site to be redirected to https, if there is a way to only redirect specific pages, that would work for me as well.

 

Thanks for your help:

 

Link to comment
Share on other sites

Well seems like it would be something to take care of on the server with .htaccess, but is there anything wrong with redirecting with a little php like this

$requireSSL = true;
// If page requires SSL, and we're not in SSL mode, 
// redirect to the SSL version of the page
if($requireSSL && $_SERVER['SERVER_PORT'] != 443) {
   header("HTTP/1.1 301 Moved Permanently");
   header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
   exit();
}

 

Thats not my code I found it  at http://www.somacon.com/p536.php, but it seems simple and effective enough.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.