Failed to redirect URL containing% 00

I want to redirect a url that contains characters and numbers, characters for another url and ... the url containing %00

at the end should redirect to another url.

Example:

www.example.com/asdnsadnas%00

redirect to another url.

%00

is not accepted in redirect url, please help me.

+3


source to share


1 answer


How you deal with this really depends on what other "characters and numbers" you mean and where in the url it happens.

Since the pattern RewriteRule

matches the url encoded% and %00

is NULL, then to catch %00

in the url path you can try to match with THE_REQUEST

which contains the original first query string (which is not% decoded).

www.example.com/asdnsadnas%00

redirect to another url.

For example, try the following at the top of your root file .htaccess

:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /asdnsadnas%00\ HTTP
RewriteRule ^asdnsadnas /another-url [R,L]

      

The template RewriteRule

just checks the first part of the url, up to %00

.

If you just wanted to redirect /asdnsadnas

and just ignore whatever follows that url, you don't need to check explicitly %00

, so you can remove the directive RewriteCond

.


www.example.com.nz/XYZABC%00

need to redirect to www.example.com.nz/insurance-hub-page/xsserror/ XYZABC

- any letter or characters, etc, but I need some url at the end to %00

need to redirect to another url.



(I'm guessing the space in the target url is just a typo?)

In this case, you don't need to match %00

(the "character" you don't need). Just list the specific characters you want to match (which will probably be a smaller subset).

For example, the following will redirect /XYZABC

to /insurance-hub-page/xsserror/XYZABC

. The rear is %00

ignored.

RewriteRule ^(\w+) /insurance-hub-page/xsserror/$1 [R,L]

      

... but I need any url at the end %00

to redirect to another url.

Not sure what you mean by that?

if the url contains any special characters or characters, etc., you need to redirect to another url. Example:www.example.com/%28dsajkd%20nkasd%20daskdasj%00

You can simply check if the requested url contains any% -encoded characters that seem to match your example:

RewriteCond %{THE_REQUEST} %
RewriteRule ^ /another-url [R,L]

      

0


source







All Articles