Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set .htaccess to use prettylinks and pass URL through as parameter
    primarykey
    data
    text
    <p>My question is very similar to this one, but for some reason the .htaccess solution there doesn't work for me: <a href="https://stackoverflow.com/questions/5513604/htaccess-url-as-parameter">htaccess url as parameter</a></p> <p>I want to pass a non-encoded URL through as a URL variable to a PHP script. It works if I do:</p> <p><a href="http://mydomain.com/url.php?url=http://google.com" rel="nofollow noreferrer">http://mydomain.com/url.php?url=http://google.com</a></p> <p>But not if I try to use prettylinks with the help of .htaccess, example:</p> <p><a href="http://mydomain.com/url/http://google.com" rel="nofollow noreferrer">http://mydomain.com/url/http://google.com</a></p> <p>My .htaccess code:</p> <pre><code>RewriteRule ^url/(.*)$ url.php?url=$1 [B,QSA] </code></pre> <p>I'm using $_GET['url'] to capture the variable in PHP and echo it. It's SUPER close, as you can see from the page output. The problem seems to be that the 2nd slash in the URL doesn't make it through:</p> <pre><code>Input URL = http:/google.com </code></pre> <p>Any ideas?</p> <p><strong>EDIT</strong></p> <p>I <em>sorta</em> fixed it by writing this PHP:</p> <pre><code>// Input vars $url = $_GET['url']; // Reformat URL because htaccess fvcks it up if (substr($url,0,6) == "http:/" &amp;&amp; substr($url,6,1) != "/") $url = str_replace("http:/","http://",$url); </code></pre> <p>But not I notice that if I add any variables to the URL variable itself, they get passed through in separate indices in the $_GET array:</p> <pre><code>http://mydomain.com/url/http://google.com/?a=123 </code></pre> <p>Results in:</p> <pre><code>$_GET = Array ( [url] =&gt; http:/google.com/ [a] =&gt; 123 ) </code></pre> <p>And</p> <pre><code>http://mydomain.com/url?url=http://google.com/?a=123 </code></pre> <p>Results in:</p> <pre><code>$_GET = Array ( [url] =&gt; http://google.com/?a=123 ) </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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