Reputation:
I have redirected url with special characters to 400 error page using .htaccess which is working fine.
I am redirecting this way.
RewriteCond %{QUERY_STRING} [^\w+=&/.()-] [OR]
RewriteCond %{REQUEST_URI} [^\w+=&/.()-]
RewriteRule .? /site/error/400/? [L,B,R]
I want to allow spaces in query too, I am trying this way but its not working.
RewriteCond %{QUERY_STRING} [^\w\s+=&/.()-] [OR]
RewriteCond %{QUERY_STRING} [^\w+=&/.()-\s] [OR]
RewriteCond %{QUERY_STRING} [^\w+=&/.()\s-] [OR]
RewriteCond %{QUERY_STRING} [^\w\d\s+=&/.()-] [OR]
Please see and suggest any possible way to do this.
Thanks.
Upvotes: 2
Views: 885
Reputation: 784868
You can use %20
for space:
RewriteCond %{QUERY_STRING} [^\w=+&/.%20()-] [OR]
RewriteCond %{REQUEST_URI} [^\w+=&/.()-]
RewriteRule ^ /site/error/400/? [L,B,R]
Upvotes: 2