1

I have an inbound link to my site which has %00 after the .html extension.

Example: /directory/example.html%00

I would like to redirect this url using htaccess to

/directory/example.html

Due to the % sign I am having problems with this redirection.

In htaccess this does not work because of the % sign.

RewriteRule ^directory/example\.html%00$ /directory/example\.html [R=301,L]

I have tried escaping the % sign with \ first.

I have searched online about this and am still struggling. Perhaps a Rewrite Condition must be implemented first? As %00 is a special character (zero hex code) apache is not given a chance to rewrite it?

Zach Saucier
  • 24,871
  • 12
  • 85
  • 147
Triple888
  • 25
  • 3

1 Answers1

1

You can see from this question and RFC 3986 that the '%' character is not valid in the URL unless it appears in the query string of the URL (after the '?' delimiter). Your RewriteRule would be correct, however the request never reaches your site since the URL is invalid. The same goes if the "%00" isn't actually a literal string but the [NUL] character (since that is also invalid in a URL).

Community
  • 1
  • 1
NathanW
  • 302
  • 2
  • 9