Console documentation - Rewrite rules

Click here to go back to "Advanced settings" documentation.


Rewrite rules are similar to those you can add in a Apache configuration file. This is a powerful way to control especially URL formatting. For example, bots may ask for captures with useless parameters in URLs. Since the SEO4Ajax crawler cannot determine if those extra parameters are useful or not, rewrite rules allow it to figure out what parameters can be safely ignored.

Rewrite rules also offer a way to return custom HTTP code like 3xx redirects. This option can be particularly useful for example when migrating from #! URLs to normal URLs by using the HTML5 history.pushState API.

Rewrite rule syntax

<regexp> [<path>] [flags]
JavaScript regular expression matching a path of the site
path (optional)
String replacing the matched path, $1..$n can be used to insert captured strings in the regular expression.
flags (optional)
  • [L] Last rule, any subsequent rewrite rules will be disregarded
  • [R=xxx] Custom HTTP code (HTTP xxx), L flag is implicit
  • [NC] Nocase, causes the path to be matched in a case-insensitive manner
  • [D] Downcase, causes the rewritten path to be downcased
  • [U] Unescape, causes the rewritten path to be unescaped (e.g. %2A will be replaced by *)
  • [NF] Not found, causes the rewrite rule to be applied only if the matching path is not already captured
  • [C] Capture, forces the capture of the matching path


Remove the trailing slash

^/(.*)\/$ /$1
This rewrite rule will transform /path/index/ to /path/index.

Remove all characters before the #! fragment

^[^#]*(.*) /$1
This rewrite rule will transform /path/index?param=value&param2=value2#!/catalog/145 to /#!/catalog/145.

Remove query parameters

^(.*)a_query_parameter=[^&]*&?(.*)$ $1$2
^(.*)another_query_parameter=[^&]*&?(.*)$ $1$2
^(.*)&$ $1
The two first rewrite rules will remove respectively a_query_parameter and another_query_parameter query parameters. The last rewrite ensures there is no trailing "&".

Redirect #! URLs to normal URLs

^/#!(.*) $1 [R=301]
This rewrite rule will transform /#!/catalog/145 to /catalog/145 and return the path in a HTTP 301 response.

Return a 404 error page

^/private$ [R=404]
This rewrite rule will return a 404 error page for /private path.

Temporary redirect and capture URLs not already captured

^/artist/(.*)/album/.*$ /artist/$1 [NF,C,R=302]
If /artist/id-1234/album/id-5678 has not already been captured, this rewrite rule will transform this path to /artist/id-1234, return the path in a HTTP 302 response and launch the capture of /artist/id-1234/album/id-5678

Unescape all escaped characters

(.*) $1 [U]
This rewrite rule will transform /path/%2B/%3A/%24/%252A to /path/+/:/$/*.

Downcase all URLs beginning by /downcase/, /Downcase/, /doWNcase/, ...

^/downcase/(.*)$ /downcase/$1 [NC,D]
This rewrite rule will transform /downCASE/AbCdEf to /downcase/abcdef.

By clicking Accept cookies you agree to the storing of third-party cookies on your device to assist us in our marking efforts (Learn more)