snipt

Ctrl+h for KB shortcuts

PHP

joomla redirect outside controller

1
2
3
4
5
6
<?php

 $app = &JFactory::getApplication();
 $app->redirect("index.php?option=com_XXXXX&view=XXXXXX&Itemid=X");

?>
https://snipt.net/embed/3ba87480ec77a46625fefa5aa56607c3/
/raw/3ba87480ec77a46625fefa5aa56607c3/
3ba87480ec77a46625fefa5aa56607c3
php
PHP
6
2019-07-23T00:08:51
True
False
False
/api/public/snipt/24575/
joomla-redirect-outside-controller
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$app</span> <span class="o">=</span> <span class="o">&amp;</span><span class="nx">JFactory</span><span class="o">::</span><span class="na">getApplication</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$app</span><span class="o">-&gt;</span><span class="na">redirect</span><span class="p">(</span><span class="s2">&quot;index.php?option=com_XXXXX&amp;view=XXXXXX&amp;Itemid=X&quot;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
application, jfactory, joomla, redirect

PHP

check SSL and redirect to SSL if not

1
2
3
4
5
     if ($_SERVER['HTTPS'] != "on") {
    $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    header("Location: $url");
    exit;
}  
https://snipt.net/embed/ba9fe48af19d756ebbce3331afb3e4c2/
/raw/ba9fe48af19d756ebbce3331afb3e4c2/
ba9fe48af19d756ebbce3331afb3e4c2
php
PHP
5
2019-07-22T23:01:12
True
False
False
/api/public/snipt/24394/
check-ssl-and-redirect-to-ssl-if-not
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x"> if ($_SERVER[&#39;HTTPS&#39;] != &quot;on&quot;) {</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> $url = &quot;https://&quot;. $_SERVER[&#39;SERVER_NAME&#39;] . $_SERVER[&#39;REQUEST_URI&#39;];</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> header(&quot;Location: $url&quot;);</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> exit;</span> </span><span id="L-5"><a name="L-5"></a><span class="x">} </span> </span></pre></div> </td></tr></table>
php, redirect, ssl