问题原文
原帖链接 · deep64blue · CC BY-SA 4.0
I have a website hosted by ionos (formerly 1&1), they have an annoying "feature" (*) whereby an incorrect page request is hijacked and sent to a third party.
The source code for the page I'm redirected to has this script:-
<script type="text/javascript">
document.write(
'<script type="text/javascript" language="JavaScript"'
+ 'src="//sedoparking.com/frmpark/'
+ window.location.host + '/'
+ 'IONOSParkingUK'
+ '/park.js">'
+ '<\/script>'
);
</script>
I was directed to this FAQ which guides me through a custom 404 error page that should prevent this
https://www.ionos.co.uk/help/hosting/html-and-css/create-your-own-error-pages-linux-webhosting
I have set up an .htaccess file like this
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /error_404.html
ErrorDocument 404 /error_404.html
and the error_404.html has this (with my own site instead of example.com):-
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Error 404</title>
</head>
<body>
<h3>This should not have happened. The page you requested does not exist (anymore).</h3>
<p><a href="https://example.com/index.php">Go to the Home page.</a></p>
</body>
</html>
I uploaded both to my website last night but on checking this morning the hijacking is still taking place.
Any ideas what I'm doing wrong? I'm on to IONOS at the moment but wanted thoughts here as well.
(*) I regard this "feature" as a security exposure and reason to move my domain elsewhere and close the account but I need this fixed in the meantime.
已采纳解答
原帖链接 · MrWhite · CC BY-SA 4.0
Make sure you're not seeing a cached response... clear your browser cache, browse with developer tools open and cache disabled (on the Network tab), incognito mode, try a different browser, etc.
That IONOS help article is misleading / dated.
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /error_404.html ErrorDocument 404 /error_404.html
Hhhmmm, this is a bit silly. You should not need the Rewrite... directives here. Delete this and try simply resetting the 404 error document to default instead:
ErrorDocument 404 default
This should serve the Apache default 404 response. If that works then consider creating a custom error document.
Aside: (Not the cause of the problem...)
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
An XML document - seriously? I doubt that you are sending an application/xml mime-type with this response.
You probably want the error response to be plain old text/html...
- Remove the XML prolog (first line).
- Change the DOCTYPE to simply
<!DOCTYPE html> - Remove the
xmlnsattribute on thehtmlelement.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
