Solved

htacces issue

Posted on 2016-09-30
2
55 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

17 Experts available now in Live!

Get 1:1 Help Now