Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>HTTPS suggestion</h1> <p>For your HTTPS issue I would match on port or HTTPS as there are known apache problems relating to the HTTPS tag.</p> <p>To cover this match on both (as shown in your edited answer)</p> <pre><code>RewriteCond %{SERVER_PORT} !^443$ [OR] RewriteCond %{HTTPS} != on ##REWRITE RULE RewriteCond %{SERVER_PORT} ^443$ [OR] RewriteCond %{HTTPS} = on ##REWRITE RULE </code></pre> <p>A valid point is also that <code>%{REQUEST_URI}</code> isn't affected by any substitutions.</p> <p>The way you are using it at the moment, if any rule matches you will send them to the original url (before any substitution started).</p> <p>If you want to take the url after and substition and matching use <code>$1</code></p> <hr> <p>Answers to your <strong>further questions</strong>:</p> <h1>If I change the case of rewrite URL then it gives error?</h1> <p>This is because your <code>[NC]</code> isn't on the rewrite cond for the HTTPS section of your .htaccess</p> <p>You match <code>RewriteCond %{REQUEST_URI} /login [OR]</code> this is only looking for lower case login, if you want to accept uppercase login append NC. </p> <hr> <h1>Is it good practice to write [NC,L] with all RewriteRule?</h1> <p>No, it depends what you want to do <code>[NC]</code> says don't match case on this rule, if you don't want to match case on that <strong>rule</strong> (or <strong>condition</strong>) then add it.</p> <p>Not matching the case with <code>[NC]</code> means site.com/login.php = sYte.cOm/LoGin.PHP</p> <p><code>[L]</code> means if this is true, stop processing everything </p> <hr> <h1>Exactly when I should write [QSA] ?</h1> <p>QSA applies when you have a ? in your substitution and you want to append toe old string to the new URL</p> <p>Consider the following rule:</p> <pre><code>RewriteRule /pages/(.+) /page.php?page=$1 [QSA] </code></pre> <p>With the <code>[QSA]</code> flag, a request for <code>/pages/123?one=two</code> will be mapped to <code>/page.php?page=123&amp;one=two</code>. Without the [QSA] flag, that same request will be mapped to <code>/page.php?page=123</code> - that is, the existing query string will be <strong>discarded</strong>.</p> <p>Do use QSA if you want to <strong>keep</strong> any additional get arguments.</p> <hr> <p>Another <strong>further question</strong></p> <h1>/login URL always changed into /login.php</h1> <p>The only way for this to happen is if you have a redirect <code>[R=301]</code> somewhere in your code, the only place I can see that is this section:</p> <pre><code># Rewrite to https RewriteCond %{SERVER_PORT} !^443$ [OR] RewriteCond %{HTTPS} != on RewriteCond %{REQUEST_URI} (/login|/do_login)\.php [NC] RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </code></pre> <p>Where this will <strong>only</strong> match the following URL's</p> <p>.php, /login.php, /do_login.php</p> <p>I believe the culprit is as I outlined in the first response with <code>%{REQUEST_URI}</code></p> <p>Your code essentially says, if these conditions are met, send them to <strong>https://theurltheywentto</strong>, which is not what you want to do, you want to send them to /login.</p> <p>Have you tried using (as mentioned in my https section)</p> <pre><code>RewriteRule ^(.*) https://%{HTTP_HOST}/login [R=301,L] </code></pre> <p>Or perhaps (if you have /do_login) and other options</p> <pre><code>RewriteRule ^(.*).php https://%{HTTP_HOST}/$1 [R=301,L] </code></pre> <p>Where test.com/do_login.php will become <a href="https://test.com/do_login" rel="nofollow">https://test.com/do_login</a></p> <p>How about you try:</p> <pre><code># Rewrite to https RewriteCond %{REQUEST_URI} (/login|/do_login)\.php [NC] RewriteCond %{HTTPS} != on RewriteRule ^(.*)\.php https://%{HTTP_HOST}/$1 [R=301,L] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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