Reputation: 31
On my site I want to block access to my xml files
For example, when the following files are requested
http://example.com/a_File.xml
or
http://example.com/some_file.xml
I want browser to redirect to a different page http://example.com/different_Page.html
.
Here is what I have in .htaccess
so far:
SetEnvIf Request_uri "\.xml$" blocked
RewriteEngine ON
RewriteCond %{ENV:blocked} ^blocked
RewriteRule (.*) 404.php [R=301]
It does not stop it, I still can view my xml file.
Upvotes: 1
Views: 1030
Reputation: 41209
Use SetEnvIfNoCase Directive to match against Request_URI String in case-insenstive manner :
SetEnvIfNoCase Request_uri "\.xml$" blocked
RewriteEngine ON
RewriteCond %{ENV:blocked} 1
RewriteRule ^(.*)$ 404.php [NC,L,R=301]
Upvotes: 0
Reputation: 7618
RewriteEngine ON
RewriteCond %{REQUEST_URI} \.xml$
RewriteRule (.*) 404.php [R=301]
Upvotes: 0
Reputation: 58860
RewriteEngine on
RewriteRule \.xml$ /different_Page.html [NC,R=301,L]
Upvotes: 1