Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you are familiar with mod_rewrite and regex a little bit, you should have no problems reading these rules -- comments are present explaining what particular rule does. the rest -- regex basics:</p> <pre><code>Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / # force https for /login.php and /register.php RewriteCond %{HTTPS} =off RewriteRule ^(login|register)\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # don't do anything for images/css/js (leave protocol as is) RewriteRule \.(gif|jpe?g|png|css|js)$ - [NC,L] # force http for all other URLs RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_URI} !^/(login|register)\.php$ RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </code></pre> <ol> <li><p>These rules need to be placed in .htaccess in website root folder BEFORE any other rewrite rules (if such present). If placed elsewhere some small tweaking may be required.</p></li> <li><p>They will </p> <ul> <li>force HTTPS for <code>/login.php</code> and <code>/register.php</code>, </li> <li>do nothing for images, css styles and JavaScript files (to be precise, for files with those extensions)</li> <li>and will force HTTP for all other URLs</li> </ul></li> <li><p>You can easily add other URLs to that list -- just edit existing rule by adding additional file name to the list (the same text in 2 places: 1) to force 2) to exclude)</p></li> <li><p>File names are case-sensitive. So these rules will not work if <code>/LOGIN.php</code> is requested (Apache will not serve it either, as Linux is case-sensitive OS .. so no need to worry much here).</p></li> <li><p>Obvious thing: mod_rewrite should be enabled and .htaccess files needs to be processed by Apache (some website hosting companies disabling them for performance and security reasons).</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload