Aside: The code you posted only blocks access to index.php
, not OmniTicker.7z
(assuming this is a physical file), so you either have other code that blocks this, or the file is entirely virtual and you are managing the download through index.php
(although other code is also required to do this)?
When you hit "Cancel" on the HTTP Authentication password prompt you are served a "401 Unauthorized" response. It looks like your host has configured this response to serve a parked/advertising page (this is not an external "redirect", as @Steve mentioned in comments).
You should be able to override this response in .htaccess
using the ErrorDocument
directive to create your own custom 401 response (just like a custom 404). For example:
ErrorDocument 401 /errordocs/my-custom-401.html
(Although I see in your earlier question that you already/previously had an ErrorDocument 401
directive defined?)
You can also try resetting the error document to the Apache default:
ErrorDocument 401 default
...it closes the popup and stays on the same page.
If by "same page", you mean the page that contained the link to OmniTicker.7z
, then... when you request OmniTicker.7z
in the browser, you have essentially moved away from the current page. Any response from the server (eg. 401 Unauthorized or the download itself, if authorized) will then replace the current page. The only way to stay on the "same page" is to somehow abort the request at the client end, "redirect" back to the previous page or use a different authentication modal. The easiest method is to display a custom 401 response (as mentioned above) with a link back to the previous page.