xoops forums

tzvook

Just can't stay away
Posted on: 5/13 15:32
tzvook
tzvook (Show more)
Just can't stay away
Posts: 875
Since: 2003/2/1 2
#1

Help with Error redirections

Hi
I need a little help with an issue I experienced lately ...
I'm using Xoops for years and never saw it before : from some reason google generates weird links to my site: https://www.mysite.com/?page_id=23 and https://www.mysite.com/?page=23 and so on ..

since Xoops always answer it with the front-page, google see all content in the front page as double content and all links as spam.

I tried redirecting with the ..htaccess without success
ErrorDocument 400 /404.php
ErrorDocument 401 
/404.php
ErrorDocument 403 
/404.php
ErrorDocument 404 
/404.php


My Configuration:
PHP: 7.2.24
XOOPS: 2.5.10

Mamba

Moderator
Posted on: 5/13 23:15
Mamba
Mamba (Show more)
Moderator
Posts: 10933
Since: 2004/4/23
#2

Re: Help with Error redirections

I couldn't find any info about such behavior, except this:
https://stackoverflow.com/questions/87 ... in-php-cant-figure-it-out

What module exactly is it doing? Are the URL links in headers of that module not generated correctly?
https://support.google.com/webmasters/answer/9112205?hl=en
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

tzvook

Just can't stay away
Posted on: 5/13 23:29
tzvook
tzvook (Show more)
Just can't stay away
Posts: 875
Since: 2003/2/1 2
#3

Re: Help with Error redirections

I don't think that something caused it ... it's probably a mistake or an old link, but the fact that XOOPS is not using some kind of ERROR page mechanism keep those links forever ... since it don't inform google that it's an Error ... and that makes all external links on your homepage "spam links" ...

All your competitors need to do is plant links like "https://xoops.org/?page=23" somewhere ... and they sabotage your site ... since now google see all homepage links on 2 pages ...

tzvook

Just can't stay away
Posted on: 5/14 13:49
tzvook
tzvook (Show more)
Just can't stay away
Posts: 875
Since: 2003/2/1 2
#4

Re: Help with Error redirections

So ?
Is there a solution to this auto redirect ?

goffy

Just can't stay away
Posted on: 5/14 19:52
goffy
goffy (Show more)
Just can't stay away
Posts: 409
Since: 2010/12/27
#5

Re: Help with Error redirections

Hi

are you using google search console? With this tool maybe you can find out where the problem is

Mamba

Moderator
Posted on: 5/15 2:36
Mamba
Mamba (Show more)
Moderator
Posts: 10933
Since: 2004/4/23
#6

Re: Help with Error redirections

Tzvook, try this module and see if it helps: https://github.com/mambax7/xhttperror

This module requires that the server supports .htaccess files (and that .htaccess files are allowed for your account), or some way for you to add custom error message redirects.

ErrorDocument 404 [xoops_url]/modules/xhttperror/index.php?error=404
ErrorDocument 500 
[xoops_url]/modules/xhttperror/index.php?error=500
ErrorDocument 403 
[xoops_url]/modules/xhttperror/index.php?error=403
ErrorDocument 403 
[xoops_url]/modules/xhttperror/index.php?error=[status code]

Where [status_code] is the status code for server errors and [xoops_url] is the URL to your main XOOPS directory WITHOUT trailing slash (http://yoursite.com)

That was a module that Luciorota was working on, so I don't know much about the internals, but in the help there were links to:
https://www.iana.org/assignments/http- ... des/http-status-codes.xml
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

To set up this module you need to:
- configure your preferences for the module;
- edit existing Errors codes or add new ones and update the .htaccess file.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

geekwright

Quite a regular
Posted on: 5/15 22:22
geekwright
geekwright (Show more)
Quite a regular
Posts: 302
Since: 2010/10/15
#7

Re: Help with Error redirections

I just want to make sure what you are asking for.

As I read this, it sounds to me that you want to intercept a URL
XOOPS_URL/?page=23
and have that instead result in an HTTP error, such as 404.

Is that correct?

Here are a few general observations.

While the link that is causing the issue is wrong, it is not technically an error. The custom error pages don't get called, as there is no HTTP error triggered. (The front page is found, and passed a query string it ignores.)

Something is creating the links that google follows. Until you find a correct that, there will still be a problem somewhere. Has anything been updated recently? As an example, I saw a module before with a XoopsPageNav error that generated links that looked a lot like this.

Goffy's suggestion about the search console sounded worthwhile.

Seeing the referrer for one of these problem URLs would pinpoint the actual source of the problem.

As a temporary solution, you could patch the XOOPS_ROOT_PATH/index.php

Adding this code on the next line after the opening "<?php" tag will cause any query string parameters to result in an error, and log the referrer if specified:
if (!empty($_GET)) {
    if (!empty(
$_SERVER['HTTP_REFERER'])) {
        @
file_put_contents(__DIR__ '/queryurllog.txt'$_SERVER['HTTP_REFERER'] . "n"FILE_APPEND);
    }
    
http_response_code(404);
    exit;
}