Using the .htaccess, I want to 301 redirect all the requests that end with default.aspx to the version without it. Like:


will be redirected to


So I use the following rewriteRule but it is throwing a 500 error:

<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^(.*)/default\.aspx$ $1 [R=301, L]

The error is:

PHP Catchable fatal error: Object of class WP_Error could not be converted to string in /site/wp-includes/kses.php on line 1248

And the related part in kses.php is:

function wp_kses_no_null( $string, $options = null ) {
    if ( ! isset( $options['slash_zero'] ) ) {
        $options = array( 'slash_zero' => 'remove' );

    $string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string ); // line 1248
    if ( 'remove' == $options['slash_zero'] ) {
        $string = preg_replace( '/\\\\+0+/', '', $string );

    return $string;

I do not see how the rewrite rule and this error is connected. And would like to know if it is possible to make such a redirect.

Thank you.

  • the 500 error come only from the rewrite rule. look in the error log of Apache and you will see the problem. – mmm Jan 26 '18 at 9:39

They aren't really connected. It's just a redirect after all.

The error means that some code in your website wrongly passes a WP_Error object to wp_kses_no_null(). In your position I'd put something like this into this function for debugging:

if ( is_wp_error( $string ) ) {
  var_dump( $string );

This way you can see exactly what the error is and where it's coming from. Maybe it's the fault of a plugin or theme, or some misconfiguration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.