Solved

htacces issue

Posted on 2016-09-30
2
39 Views
Last Modified: 2016-11-07
I have an issue with my htaccess file.  

I have a site / wordpress. http://www. MYSITE.com/learn/test.php but when I navigate there it does not force https
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.MYSITE.com/$1 [L,R=301]
RewriteBase /learn/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /learn/index.php [L]
</IfModule>

Open in new window

0
Comment
Question by:rgranlund
2 Comments
 
LVL 2

Accepted Solution

by:
Dillyn Barber earned 500 total points
ID: 41824365
You can do a php cheat as such:
if (!isset($_SERVER['HTTPS']) || !$_SERVER['HTTPS']) { // if request is not secure, redirect to secure url
    $url = 'https://' . $_SERVER['HTTP_HOST']
                      . $_SERVER['REQUEST_URI'];

    header('Location: ' . $url);
    exit;
}

Open in new window


you would place this code at the begining of the test.php file or, try this in your htaccess for the single php page
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*)  https://www. MYSITE.com/learn/test.php [R]
</IfModule>

Open in new window


Note: htaccess syntax can vary from type of server but it is most commonly used with Apache.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to dynamically set the form action using jQuery.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now