Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not a php guy, but I tried this with my rewrite.</p> <pre><code>RewriteRule ^/(.+)/([^/]+)$ /index.php?p=$1&amp;uid=$2 [L] </code></pre> <p>In this case, for the <code>p</code> parameter, you're looking for all chars up to the last slash, so the first part of this takes anything, otherwise it's going to stop at the first slash (users instead of users/profile).</p> <p>Then it looks for a slash and keep (not-slash). The <code>(.+)</code> will be greedy, so it will go up to the last slash before the end.</p> <p>Then it occurred to me the last part doesn't need to avoid slashes. Since the first part is greedy, the explicit <code>/</code> slash is going to BE the last slash. So it's even simpler:</p> <pre><code>RewriteRule ^/(.+)/(.+)$ /index.php?p=$1&amp;uid=$2 [L] </code></pre> <p>I like the <code>.+</code> to require something, at least when first figuring these out. If later you know they can be optional, you can do <code>.*</code>, but usually that ends up being a different page or a different rule.</p> <p>These rules do expect all urls to be in this format, which is what you're asking. But maybe it's a little too grabby, so it could exclude urls that really have a .htm or .php or whatever. </p> <pre><code>RewriteRule ^/(.+)/([^.]+)$ /index.php?p=$1&amp;uid=$2 [L] </code></pre> <p>This looks for anything up to the last slash, then anything without a dot in it. If it has a dot, this won't apply. So if it's a "regular" url, this will leave it alone. This might help with the 404 problem, in case the 404 page is getting caught by this.</p>
 

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