Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This should do what you're looking for. We're parsing the server variable query string <code>%{QUERY_STRING}</code> for the <code>GET</code> variable <code>id</code>. We don't want the first part of the variable, so we're not going to capture it inside of our RegEx group <code>()</code>; the part in the parenthesis should be what you're looking for. Also we're going to try and end it before any other variable in the query string by looking for anything that is not an <code>&amp;</code> character. Then we look for a possible literal <code>&amp;</code> character.</p> <p>We use the <code>%1</code> to echo the captured string in our rule, then we append the slash and add a <code>?</code> mark to show that we do not what the behavior of <code>[QSA] Query String Append</code>. We're telling it we want a redirect, so we pass it <code>R</code> and <code>L</code> for last. If you want it to be a permanent redirect you can use <code>[R=301]</code>.</p> <pre><code>RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} id=\d+:([^&amp;]+)&amp;? RewriteRule .* %1/? [R,L] </code></pre> <p><code>.htaccess</code> is better (quicker), but to do this in PHP you would want to edit the code that creates this link first. However, if you're trying to change this link on the page once the page loads you can do this (at the top of the page):</p> <pre><code>if(preg_match('!^/index\.php!',$_SERVER['REQUEST_URI'])){ if(!empty($_GET['id'])){ $id=$_GET['id']; $parts = explode(':',$id); $newPath = 'Location: /'.$parts[1].'/'; header($newPath); exit(); } } </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.
 

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