Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To limit the rule to certain requests, you'll need to use <code>RewriteCond</code>. You can find the documentation on those <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond" rel="nofollow">here</a>.</p> <p>To only let it work for <code>www.domain.com/directory/</code> you can add this to the RewriteRule itself. Please note that you are using a permanent redirect, so any change you currently will make will not work until you clear the cache from the browser for your site.</p> <pre><code>RewriteRule ^directory/([^_]*)_([^_]*_.*) /directory/$1-$2 [N] RewriteRule ^directory/([^_]*)_([^_]*)$ /directory/$1-$2 [L,R] </code></pre> <p>To exclude css and js files, you can use something like this. This will exclude (<code>!</code>) files that end on <code>.css</code> or <code>.js</code> (<code>\.(css|js)</code>).</p> <pre><code>RewriteCond %{REQUEST_URI} !\.(css|js)$ RewriteRule ^directory/([^_]*)_([^_]*_.*) /directory/$1-$2 [N] RewriteRule ^directory/([^_]*)_([^_]*)$ /directory/$1-$2 [L,R] </code></pre> <p>I can't test these rules and I encourage you to set up a simple localhost server to test things on before doing them on your live site. If you are testing redirects on a site, <em>always</em> use temporary redirects (<code>[R]</code>) instead of permanent redirects (<code>[R=301]</code>). Permanent redirects are cached by the browser and reduce the load on the server for subsequent requests, but if you are testing, it will remember a previous attempt. Only change temporary redirects to permanent redirects after all rules work as you want them to work.</p>
    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. 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